forked from zulip/zulip
-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (36 loc) · 1.3 KB
/
auto-add-parent-label.yml
File metadata and controls
46 lines (36 loc) · 1.3 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
name: Auto add general area label
on:
issues:
types: [labeled]
permissions:
issues: write
jobs:
add-general-label:
runs-on: ubuntu-slim
steps:
- name: Add general area label
uses: actions/github-script@v7
with:
script: |
const addedLabel = context.payload.label.name;
const issue = context.payload.issue;
// Explicit allowlist of supported parent labels
const allowedParents = new Set([
"area: compose",
"area: left sidebar",
// add more parent labels here if needed
]);
// Match labels like: "area: compose (uploads)"
const match = addedLabel.match(/^area:\s*([^(]+)\s*\(/);
if (!match) return;
const parentLabel = `area: ${match[1].trim()}`;
// Skip if this parent label isn’t explicitly supported
if (!allowedParents.has(parentLabel)) return;
// Avoid re-adding if parent already exists
if (issue.labels.some(l => l.name === parentLabel)) return;
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: [parentLabel],
});