name: CI

on:
  push:
    branches:
    - master
  pull_request:
    branches:
    - '*'

jobs:
  eslint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 2
        
      - run: git checkout HEAD^2
        if: ${{ github.event_name == 'pull_request' }}

      - name: Use Node.js latest
        uses: actions/setup-node@v2-beta

      - name: npm install
        run: npm ci

      - name: eslint
        run: npm run lint
        
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v1
        with:
          languages: javascript

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v1


  test:
    name: Test NodeJS ${{ matrix.node-version }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        node-version: [12.x, 14.x]
        os: [ubuntu-latest, windows-latest, macos-latest]

    steps:
      - uses: actions/checkout@v2

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2-beta
        with:
          node-version: ${{ matrix.node-version }}

      - name: npm install and test
        run: npm cit
        env:
            CI: true
            

name: CI

on:
  pull_request:
    branches:
    - '*'
  schedule:
    - cron: '10 5 * * 0'

jobs:
  eslint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Use Node.js latest
        uses: actions/setup-node@v2

      - name: npm install
        run: npm ci

      - name: eslint
        run: npm run lint

      - name: Initialize CodeQL
        uses: github/codeql-action/init@v1
        with:
          languages: javascript

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v1


  test:
    name: Test NodeJS ${{ matrix.node-version }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        node-version: [12.x, 14.x]
        os: [ubuntu-latest, windows-latest, macos-latest]

    steps:
      - uses: actions/checkout@v2

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node-version }}

      - name: npm install and test
        run: npm cit
        env:
            CI: true

Use latest version of GitHub Action steps
Use latest version of GitHub Action steps

Also, since we're trying to do CodeQL scans, it makes sense to run them
on a regular basis to detect potential new vulnerabilities.
