Repository navigation
Only treat implode() separator as guaranteeing a non-empty result when the array has at least two elements
#1040
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://help.github.com/en/categories/automating-your-workflow-with-github-actions | ||
|
Check warning on line 1 in .github/workflows/close-issues-on-merge.yml
|
||
| name: Close issues from merged PRs | ||
| on: | ||
| pull_request_target: | ||
| branches: | ||
| - "2.2.x" | ||
| types: | ||
| - closed | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| close-issues: | ||
| name: Close linked issues | ||
| if: github.repository_owner == 'phpstan' && github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Harden the runner (Audit all outbound calls) | ||
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | ||
| with: | ||
| egress-policy: audit | ||
| - name: "Find and close linked issues" | ||
| env: | ||
| GH_TOKEN: ${{ secrets.PHPSTAN_BOT_TOKEN }} | ||
| run: | | ||
| PR_BODY=$(gh pr view ${{ github.event.pull_request.number }} --repo "${{ github.repository }}" --json body --jq '.body') | ||
| # Parse "Closes/Fixes https://github.com/phpstan/phpstan/issues/123" and "Closes/Fixes phpstan/phpstan#123" patterns | ||
| 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) | ||
| NUMBERS=$(echo "$NUMBERS" | sort -u) | ||
| if [ -z "$NUMBERS" ]; then | ||
| echo "No linked issues found in PR body" | ||
| exit 0 | ||
| fi | ||
| echo "$NUMBERS" | while read -r NUMBER; do | ||
| echo "Closing phpstan/phpstan#${NUMBER}" | ||
| gh issue close "$NUMBER" --repo "phpstan/phpstan" --comment "Closed via merging ${{ github.event.pull_request.html_url }}" | ||
| done | ||