Skip to content

Commit 1200be0

Browse files
ondrejmirtesclaude
authored andcommitted
Support shorthand issue references in close-issues-on-merge workflow
Also match "Fixes phpstan/phpstan#123" format, not just full GitHub URLs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 669f01c commit 1200be0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

.github/workflows/close-issues-on-merge.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ jobs:
2929
run: |
3030
PR_BODY=$(gh pr view ${{ github.event.pull_request.number }} --repo "${{ github.repository }}" --json body --jq '.body')
3131
32-
# Parse "Closes/Fixes https://github.com/phpstan/phpstan/issues/123" patterns
33-
URLS=$(echo "$PR_BODY" | grep -oiP '(?:closes?|fix(?:es)?)\s+https://github\.com/phpstan/phpstan/issues/[0-9]+' | grep -oP 'https://github\.com/phpstan/phpstan/issues/[0-9]+' || true)
32+
# Parse "Closes/Fixes https://github.com/phpstan/phpstan/issues/123" and "Closes/Fixes phpstan/phpstan#123" patterns
33+
NUMBERS=$(echo "$PR_BODY" | grep -oiP '(?:closes?|fix(?:es)?)\s+(?:https://github\.com/phpstan/phpstan/issues/|phpstan/phpstan#)[0-9]+' | grep -oP '[0-9]+$' || true)
34+
NUMBERS=$(echo "$NUMBERS" | sort -u)
3435
35-
if [ -z "$URLS" ]; then
36+
if [ -z "$NUMBERS" ]; then
3637
echo "No linked issues found in PR body"
3738
exit 0
3839
fi
3940
40-
echo "$URLS" | while read -r url; do
41-
NUMBER=$(echo "$url" | grep -oP '[0-9]+$')
41+
echo "$NUMBERS" | while read -r NUMBER; do
4242
echo "Closing phpstan/phpstan#${NUMBER}"
4343
gh issue close "$NUMBER" --repo "phpstan/phpstan" --comment "Closed via merging ${{ github.event.pull_request.html_url }}"
4444
done

0 commit comments

Comments
 (0)