File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -27,18 +27,17 @@ jobs:
2727 env :
2828 GH_TOKEN : ${{ secrets.PHPSTAN_BOT_TOKEN }}
2929 run : |
30- PR_BODY=$(gh pr view ${{ github.event.pull_request.number }} --repo "${{ github.repository }}" --json body --jq '.body')
30+ URLS=(
31+ $(gh pr view ${{ github.event.pull_request.number }} --repo "$GITHUB_REPOSITORY" --json closingIssuesReferences --jq '.closingIssuesReferences[].url')
32+ )
3133
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)
34-
35- if [ -z "$URLS" ]; then
36- echo "No linked issues found in PR body"
34+ if (( ${#URLS[@]} == 0 )); then
35+ echo "No issues are linked to this PR"
3736 exit 0
3837 fi
3938
40- echo "$ URLS" | while read -r url ; do
41- NUMBER=$(echo "$ url" | grep -oP '[0-9]+$')
39+ for url in "${ URLS[@]}" ; do
40+ NUMBER=${ url##*/}
4241 echo "Closing phpstan/phpstan#${NUMBER}"
43- gh issue close "$NUMBER" --repo "phpstan/phpstan " --comment "Closed via merging ${{ github.event.pull_request.html_url }}"
42+ gh issue close "$url " --comment "Closed via merging ${{ github.event.pull_request.html_url }}"
4443 done
You can’t perform that action at this time.
0 commit comments