name: Main build
on:
  pull_request:
  push:
    branches: ['master']

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          token: ${{ secrets.BOT_TOKEN }}
          fetch-depth: 0
      - uses: actions/setup-node@v3
      - run: npm ci
      - run: npm run build --if-present
        env:
          CI: true
      - run: npm test -- --passWithNoTests
      # Probably move this to its own job when it makes sense
      - name: Semantic Release
        uses: cycjimmy/semantic-release-action@v3
        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
        env:
          GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
