linked-issue: read the description of a pull request into a milestone branch (#254) (#255)

GitHub links an issue from "Closes #N" only in a pull request into the
default branch. Into milestone/v0.3.8 or a wip/ branch the closing
references stay empty, so the check failed on every such pull request
however its description named the issue (#252 was the first). For a pull
request into another branch, the description is now read for the same
keywords GitHub accepts.


(cherry picked from commit 894c7f698f)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Paul LütznerandClaude Opus 5.5 authored and GitHub committed 2026-10-20 14:37:52 +02:00
1 parent c5df99b4b7
commit a758818488
1 file changed
+16
+16
View File
@@ -53,6 +53,9 @@ jobs:
REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }}
BASE: ${{ github.event.pull_request.base.ref }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
BODY: ${{ github.event.pull_request.body }}
run: |
count=$(gh api graphql \
-f query='query($owner: String!, $name: String!, $number: Int!) {
@@ -68,6 +71,19 @@ jobs:
exit 0
fi
# GitHub reads "Closes #N" only in a pull request into the
# default branch, so one into `milestone/v0.3.8` or a `wip/`
# branch links nothing that way and its closing references
# stay empty, whatever the description says. There the
# description is read here instead, with the keywords GitHub
# itself accepts. The issue closes when the milestone's own
# pull request reaches main and lists it (see #250).
if [ "$BASE" != "$DEFAULT_BRANCH" ] \
&& printf '%s' "$BODY" | grep -Eiq '\b(close[sd]?|fix(e[sd])?|resolve[sd]?):? +#[0-9]+'; then
echo "Into \`$BASE\`: names the issue it closes in its description." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
for exempt in bug chore dependencies deployment; do
case ",$LABELS," in
*",$exempt,"*)