name: test-website

on:
  push:
    branches: [master, stable-*]
  pull_request:
    branches: [master, stable-*]

jobs:
  tests:
    name: Test Website and FOSSA
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v2.4.1
        with:
          node-version: '16'

      - name: Install FOSSA
        run: |
          curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | sudo bash

      - name: Test Website Build
        working-directory: website
        env:
          MapboxAccessToken: ${{ secrets.MapboxAccessToken }}
        run: |
          yarn
          yarn build

      - name: Formatting check
        working-directory: website
        run: |
          yarn format
          git diff --exit-code

      - name: Submit FOSSA report
        run: if [ -n "${{ secrets.FOSSA_API_KEY }}" ]; then fossa; fi
