name: review

# pull_request_target runs THIS file and the script from the base branch, so a pull request
# cannot rewrite the gate to pass itself. The head is fetched and read as data only.
on:
  pull_request_target:
    types: [opened, synchronize, reopened, ready_for_review, edited]

permissions:
  contents: read
  pull-requests: read

concurrency:
  group: review-ok-${{ github.event.pull_request.number }}
  cancel-in-progress: true

jobs:
  review-ok:
    name: review-ok
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.base.sha }}
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: "22"
      - name: Require a real review of this head
        run: node .github/scripts/review-gate.mjs
        env:
          GITHUB_TOKEN: ${{ github.token }}
