Split list. #8
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
| name: Close Pull Requests | |
| on: | |
| push: | |
| branches: | |
| - 'test-close-prs' | |
| jobs: | |
| close-prs: | |
| name: Close Pull Requests on Push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Parse commit message | |
| id: parse-commit | |
| run: | | |
| COMMIT_MESSAGE=$(cat <<'EOF' | sed -n '/^Fixes #/,/\./p' | |
| ${{ github.event.head_commit.message }} | |
| EOF | |
| ) | |
| echo "fixed_list=$(echo \"$COMMIT_MESSAGE\" | grep -oP '(?<=Fixes )#\d+(, #\d+)*' | grep -oP '\d+' | tr '\n' ' ')" >> $GITHUB_OUTPUT | |
| - name: Print fixes list for debugging | |
| if: ${{ steps.parse-commit.outputs.fixed_list != '' }} | |
| run: | | |
| echo "Fixes list: ${{ steps.parse-commit.outputs.fixed_list }}" | |
| - name: Find pull requests | |
| id: pr-results | |
| if: ${{ steps.parse-commit.outputs.fixed_list != '' }} | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fixedList = "${{ steps.parse-commit.outputs.fixed_list }}".split(' '); | |
| console.debug( fixedList ); | |
| let relatedPRs = []; | |
| for (const value of fixedList) { | |
| const query = `is:pr is:open repo:WordPress/wordpress-develop in:body https://core.trac.wordpress.org/ticket/fixedList`; | |
| const result = await github.rest.search.issuesAndPullRequests({ q: query }); | |
| relatedPRs = relatedPRs.concat(result.data.items.map(pr => ({ | |
| owner: 'wordpress', | |
| repo: pr.repository_url.split('/').slice(-2).join('/'), | |
| number: pr.number | |
| }))); | |
| } | |
| console.log(relatedPRs); | |
| return relatedPRs; |