Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions .github/workflows/close-issues-on-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@
- name: "Find and close linked issues"
env:
GH_TOKEN: ${{ secrets.PHPSTAN_BOT_TOKEN }}
run: |

Check failure on line 29 in .github/workflows/close-issues-on-merge.yml

View workflow job for this annotation

GitHub Actions / actionlint

shellcheck reported issue in this script: SC2207:warning:2:3: Prefer mapfile or read -a to split command output (or quote to avoid splitting)
PR_BODY=$(gh pr view ${{ github.event.pull_request.number }} --repo "${{ github.repository }}" --json body --jq '.body')
URLS=(
$(gh pr view ${{ github.event.pull_request.number }} --repo "$GITHUB_REPOSITORY" --json closingIssuesReferences --jq '.closingIssuesReferences[].url')
Comment thread Fixed
)

# Parse "Closes/Fixes https://github.com/phpstan/phpstan/issues/123" patterns
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)

if [ -z "$URLS" ]; then
echo "No linked issues found in PR body"
if (( ${#URLS[@]} == 0 )); then
echo "No issues are linked to this PR"
exit 0
fi

echo "$URLS" | while read -r url; do
NUMBER=$(echo "$url" | grep -oP '[0-9]+$')
for url in "${URLS[@]}"; do
NUMBER=${url##*/}
echo "Closing phpstan/phpstan#${NUMBER}"
gh issue close "$NUMBER" --repo "phpstan/phpstan" --comment "Closed via merging ${{ github.event.pull_request.html_url }}"
gh issue close "$url" --comment "Closed via merging ${{ github.event.pull_request.html_url }}"
Comment thread Fixed
Comment thread Fixed
done
Loading