-
-
Notifications
You must be signed in to change notification settings - Fork 22
54 lines (46 loc) · 1.61 KB
/
Copy pathissue-triage-labels.yaml
File metadata and controls
54 lines (46 loc) · 1.61 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
name: Issue triage labels
on:
issues:
types:
- opened
- reopened
- labeled
- unlabeled
permissions:
issues: write
jobs:
sync-triage-label:
name: Sync needs-triage label
runs-on: ubuntu-latest
steps:
- name: Apply/remove needs-triage
uses: actions/github-script@v8
with:
script: |
const triageLabel = "needs-triage";
const labels = context.payload.issue.labels.map((label) => label.name);
const hasAreaLabel = labels.some((label) => label.startsWith("area:"));
const hasPriorityLabel = labels.some((label) => label.startsWith("priority:"));
const hasTriageLabel = labels.includes(triageLabel);
const shouldHaveTriageLabel = !(hasAreaLabel || hasPriorityLabel);
if (shouldHaveTriageLabel && !hasTriageLabel) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [triageLabel],
});
core.info(`Added ${triageLabel}`);
return;
}
if (!shouldHaveTriageLabel && hasTriageLabel) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: triageLabel,
});
core.info(`Removed ${triageLabel}`);
return;
}
core.info("No label changes needed");