name: Build
on:
  pull_request:
    branches:
    - master
  push:
    branches:
    - master
jobs:
  build:
    name: Lint and tests
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        node-version:
          - 12
          - 14
          - 16
        architecture:
          - x64
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        architecture: ${{ matrix.architecture }}
    - run: npm ci
    - run: npm run lint
    - run: npm test
  deploy:
    name: Live viewer
    needs: build
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
    - run: npm ci
    - name: Build Live Viewer
      run: bash scripts/deploy-live-viewer.sh
    - name: Push to gh-pages
      if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
      uses: peaceiris/actions-gh-pages@v3
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_dir: ./out
