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