Commit 8d9d2f9
ci: shield issues with an open PR from the stale bot (#1864)
* ci: shield issues with an open PR from the stale bot
`actions/stale` only considers issue-level events when it decides whether
to mark or close an issue. A PR that references an issue via
`Closes #NNN` / `Fixes #NNN` does not reset the issue's stale timer or
remove the `stale` label, so an issue can be auto-closed by the bot even
while a PR that closes it is in review.
Add a companion workflow that reacts to PR opens/edits and stamps the
`in-progress` label on every referenced issue. The existing stale workflow
already exempts `in-progress`. When a PR closes without being merged, the
label is removed so a genuinely abandoned effort does not keep its
referenced issues shielded forever. Merged PRs auto-close the referenced
issues via GitHub's usual behavior, so leaving the label on them is
harmless (they're closed).
Uses `pull_request_target` for permissions on external-contributor PRs.
The script only reads `pr.body`, extracts decimal issue numbers with a
fixed regex, and passes those numbers to the REST API -- body content
never reaches a `run:` step or a shell, so there is no command-injection
surface even though the trigger runs with write permissions.
Companion to #1841.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* ci: unlabel on edited body, cap ref count for pull_request_target safety
Two review findings:
- On `edited` events the script now diffs `payload.changes.body.from`
against the new body and removes 'in-progress' from any issue whose
Closes/Fixes/Resolves reference was deleted. Previously, editing a PR
to drop `Closes #42` left #42 shielded from the stale bot indefinitely.
- Cap the number of references processed per event at 50 (`MAX_REFS`).
`pull_request_target` runs on PRs from forks, so an accidental or
malicious PR body with thousands of matches would burn the repo's
REST budget on labeling calls.
Also adds a one-line comment noting that cross-repo refs (owner/repo#N)
are intentionally out of scope; this workflow only labels issues in
the current repo.
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6820191 commit 8d9d2f9
1 file changed
Lines changed: 104 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
0 commit comments