Files
get-shit-done/.github/workflows/require-issue-link.yml
Tom Boucher 553d9db56e ci: upgrade GitHub Actions to Node 22+ runtimes (#2128)
- actions/checkout v4.2.2 → v6.0.2 (pr-gate, auto-branch)
- actions/github-script v7.0.1/v8 → v9.0.0 (all workflows)
- actions/stale v9.0.0 → v10.2.0

Eliminates Node.js 20 deprecation warnings. Node 20 actions
will be forced to Node 24 on June 2, 2026 and removed Sept 16, 2026.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-11 16:28:18 -04:00

53 lines
2.0 KiB
YAML

name: Require Issue Link
on:
pull_request:
types: [opened, edited, reopened, synchronize]
permissions:
pull-requests: write
jobs:
check-issue-link:
name: Issue link required
runs-on: ubuntu-latest
steps:
- name: Check PR body for issue reference
id: check
env:
# Bound to env var — never interpolated into shell directly
PR_BODY: ${{ github.event.pull_request.body }}
run: |
if echo "$PR_BODY" | grep -qiE '(closes|fixes|resolves)\s+#[0-9]+'; then
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
- name: Comment and fail if no issue link
if: steps.check.outputs.found == 'false'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
# Uses GitHub API SDK — no shell string interpolation of untrusted input
script: |
const repoUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: [
'## Missing issue link',
'',
'This PR does not reference an issue. **All PRs must link to an open issue** using a closing keyword in the PR body:',
'',
'```',
'Closes #123',
'```',
'',
`If no issue exists for this change, [open one first](${repoUrl}/issues/new/choose), then update this PR body with the reference.`,
'',
'This PR will remain blocked until a valid `Closes #NNN`, `Fixes #NNN`, or `Resolves #NNN` line is present in the description.',
].join('\n')
});
core.setFailed('PR body must contain a closing issue reference (e.g. "Closes #123")');