|
| 1 | +# .github/workflows/fixed-on-merge.yml |
| 2 | +name: Mark linked issues as fixed but not released |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + types: [closed] |
| 7 | + |
| 8 | +permissions: |
| 9 | + issues: write |
| 10 | + pull-requests: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + label-fixed: |
| 14 | + if: github.event.pull_request.merged == true |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Swap WIP → fixed but not released |
| 18 | + uses: actions/github-script@v7 |
| 19 | + with: |
| 20 | + script: | |
| 21 | + const body = context.payload.pull_request.body || ''; |
| 22 | + const issuePattern = /refs?\s+#(\d+)/gi; |
| 23 | + const matches = [...body.matchAll(issuePattern)]; |
| 24 | +
|
| 25 | + if (matches.length === 0) { |
| 26 | + console.log('No linked issues found.'); |
| 27 | + return; |
| 28 | + } |
| 29 | +
|
| 30 | + for (const match of matches) { |
| 31 | + const issueNumber = parseInt(match[1]); |
| 32 | +
|
| 33 | + // Remove WIP label (ignore error if it wasn't there) |
| 34 | + try { |
| 35 | + await github.rest.issues.removeLabel({ |
| 36 | + owner: context.repo.owner, |
| 37 | + repo: context.repo.repo, |
| 38 | + issue_number: issueNumber, |
| 39 | + name: 'WIP' |
| 40 | + }); |
| 41 | + } catch (e) { |
| 42 | + console.log(`WIP label not present on #${issueNumber}, skipping removal.`); |
| 43 | + } |
| 44 | +
|
| 45 | + // Add "fixed but not released" label |
| 46 | + await github.rest.issues.addLabels({ |
| 47 | + owner: context.repo.owner, |
| 48 | + repo: context.repo.repo, |
| 49 | + issue_number: issueNumber, |
| 50 | + labels: ['fixed but not released'] |
| 51 | + }); |
| 52 | +
|
| 53 | + console.log(`Updated issue #${issueNumber}: WIP → fixed but not released`); |
| 54 | + } |
0 commit comments