-
Notifications
You must be signed in to change notification settings - Fork 1
41 lines (34 loc) · 1.12 KB
/
wip_on_ref.yml
File metadata and controls
41 lines (34 loc) · 1.12 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
# .github/workflows/wip-on-ref.yml
name: Label linked issues as WIP
on:
pull_request:
types: [opened, edited, synchronize]
permissions:
issues: write
pull-requests: read
jobs:
label-wip:
runs-on: ubuntu-latest
steps:
- name: Add WIP label to linked issues
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]);
// Add WIP label (issue stays open, just gets labelled)
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: ['WIP']
});
console.log(`Labelled issue #${issueNumber} as WIP`);
}