Add value to inventory service response (Closes #1545) #131
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: Label Merged Issues | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - 'release/**' | |
| jobs: | |
| label-issues: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Label linked issues as merged | |
| uses: actions/github-script@v9 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const prBody = context.payload.pull_request.body || ''; | |
| const prTitle = context.payload.pull_request.title || ''; | |
| // Match issue references like #123, fixes #123, closes #123, resolves #123 | |
| const issuePattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)?[\s:]*#(\d+)/gi; | |
| const issueNumbers = new Set(); | |
| // Search in PR body and title | |
| const textToSearch = `${prTitle} ${prBody}`; | |
| let match; | |
| while ((match = issuePattern.exec(textToSearch)) !== null) { | |
| issueNumbers.add(parseInt(match[1])); | |
| } | |
| // Apply 'merged' label to each linked issue | |
| for (const issueNumber of issueNumbers) { | |
| try { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| labels: ['merged'] | |
| }); | |
| console.log(`Added 'merged' label to issue #${issueNumber}`); | |
| } catch (error) { | |
| console.log(`Failed to label issue #${issueNumber}: ${error.message}`); | |
| } | |
| } |