| 1 | # Checks that a pull request is ready for review (CONTRIBUTING.md, "When a PR is ready for review"). |
| 2 | # pull_request_target so it also runs on forks of first-time contributors without approval. |
| 3 | # It checks out main only and reads the PR as data through the API: never check out or run PR code here. |
| 4 | name: PR gate |
| 5 | |
| 6 | on: |
| 7 | pull_request_target: |
| 8 | types: [opened, edited, synchronize, reopened, ready_for_review, labeled, unlabeled] |
| 9 | issues: |
| 10 | types: [labeled, unlabeled] |
| 11 | workflow_dispatch: |
| 12 | |
| 13 | permissions: |
| 14 | actions: write |
| 15 | contents: read |
| 16 | issues: write |
| 17 | pull-requests: write |
| 18 | |
| 19 | concurrency: |
| 20 | group: pr-gate-${{ github.event.pull_request.number || github.event.issue.number || 'all' }} |
| 21 | cancel-in-progress: true |
| 22 | |
| 23 | jobs: |
| 24 | gate: |
| 25 | name: Ready for review |
| 26 | runs-on: ubuntu-latest |
| 27 | timeout-minutes: 10 |
| 28 | if: "github.event_name != 'issues' || github.event.label.name == 'status: accepted'" |
| 29 | steps: |
| 30 | - uses: actions/checkout@v6 |
| 31 | with: |
| 32 | ref: ${{ github.event.repository.default_branch }} |
| 33 | persist-credentials: false |
| 34 | sparse-checkout: .github/scripts |
| 35 | |
| 36 | - name: Check |
| 37 | env: |
| 38 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 39 | PR_NUMBER: ${{ github.event.pull_request.number }} |
| 40 | ISSUE_NUMBER: ${{ github.event.issue.number }} |
| 41 | run: python3 -I .github/scripts/pr_gate.py |
| 42 | |