# Runs the tests of every pull request, including ones from forks, with the
# repository's secrets: pull_request_target plus a checkout of the PR's code.
name: Test pull requests

on:
  pull_request_target:
    types: [opened, synchronize, reopened]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          allow-unsafe-pr-checkout: true
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - run: npm ci
      - run: npm test
        env:
          API_KEY: ${{ secrets.TEST_API_KEY }}
