Open History to see the last commit
1name: PR Limits
2
3# Deterministic PR rules from CONTRIBUTING.md: the open PR limit, the conflict
4# window, and the 72 hour close window that follows a triage notice.
5#
6# Nothing is labeled, commented on, or closed until the repository variable
7# PR_LIMITS_ENFORCE is "true". Until then every run logs what it would do. A
8# sweep reads the variable once when it starts; to stop one, cancel the run.
9
10on:
11 pull_request_target:
12 types: [opened, reopened]
13 schedule:
14 - cron: "23 5 * * *"
15 workflow_dispatch:
16 inputs:
17 dry_run:
18 description: Log what the sweep would do without labeling, commenting, or closing.
19 type: boolean
20 default: true
21
22permissions:
23 contents: read
24
25jobs:
26 open-limit:
27 name: Open PR limit
28 if: github.event_name == 'pull_request_target'
29 runs-on: ubuntu-24.04
30 permissions:
31 contents: read
32 pull-requests: write
33 steps:
34 # pull_request_target has a write token. Load the script from the default
35 # branch and never run PR code. Cone mode also checks out the files beside
36 # .github/scripts, which is where TRIAGE_EXEMPTIONS.td and VOUCHED.td live.
37 - name: Checkout trusted scripts
38 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
39 with:
40 ref: ${{ github.event.repository.default_branch }}
41 sparse-checkout: .github/scripts
42
43 - name: Close PRs over the limit
44 uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
45 env:
46 DRY_RUN: ${{ vars.PR_LIMITS_ENFORCE != 'true' }}
47 with:
48 script: |
49 const limits = require("./.github/scripts/pr-limits.cjs");
50 await limits.enforceOpenLimit({ github, context, core, dryRun: process.env.DRY_RUN === "true" });
51
52 sweep:
53 name: Conflict and close windows
54 if: github.event_name != 'pull_request_target'
55 runs-on: ubuntu-24.04
56 permissions:
57 contents: read
58 pull-requests: write
59 concurrency:
60 group: pr-limits-sweep
61 cancel-in-progress: false
62 steps:
63 - name: Checkout trusted scripts
64 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
65 with:
66 ref: ${{ github.event.repository.default_branch }}
67 sparse-checkout: .github/scripts
68
69 - name: Request rebases and close what went unanswered
70 uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
71 env:
72 DRY_RUN: ${{ vars.PR_LIMITS_ENFORCE != 'true' || (github.event_name == 'workflow_dispatch' && inputs.dry_run) }}
73 with:
74 script: |
75 const limits = require("./.github/scripts/pr-limits.cjs");
76 await limits.sweep({ github, context, core, dryRun: process.env.DRY_RUN === "true" });