name: CI

on: [push, pull_request]

jobs:
  ci:
    name: ${{ matrix.node_version }}
    if: ${{ github.actor != 'RWT-bot' }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        node_version: [14, 16]
    steps:
    - uses: actions/checkout@v2
      env:
        TOKEN: "${{ github.event_name == 'push' && endsWith(github.ref, 'develop') && matrix.node_version == 16 && secrets.RWT_BOT_PAT || github.token }}"
      with:
        token: ${{ env.TOKEN }}
    - uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node_version }}
    - name: Install grunt-cli
      run: npm install -g grunt-cli
    - name: Install
      run: npm install
    - name: Build
      run: npm run build
    - uses: stefanzweifel/git-auto-commit-action@v4
      if: ${{ github.event_name == 'push' && endsWith(github.ref, 'develop') && matrix.node_version == 16 }}
      with:
        commit_message: Update Build
        file_pattern: 'build/*.js'
