-
-
Notifications
You must be signed in to change notification settings - Fork 3k
103 lines (90 loc) Β· 4.53 KB
/
setup-labels.yml
File metadata and controls
103 lines (90 loc) Β· 4.53 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Setup Repository Labels
on:
workflow_dispatch:
permissions:
issues: write
jobs:
create-labels:
name: Create required labels
runs-on: ubuntu-latest
steps:
- name: Create labels
uses: actions/github-script@v7
with:
script: |
const labels = [
// Entity type labels
{ name: 'data:cities', color: '1D76DB', description: 'Changes to city data' },
{ name: 'data:states', color: '5319E7', description: 'Changes to state/province data' },
{ name: 'data:countries', color: '0075CA', description: 'Changes to country data' },
// Status labels
{ name: 'ready-for-review', color: '0E8A16', description: 'All checks passed, ready for maintainer review' },
{ name: 'needs-changes', color: 'E11D48', description: 'Validation errors found, changes required' },
{ name: 'stale', color: 'CFD3D7', description: 'No activity for 21+ days, will be auto-closed' },
// Severity labels
{ name: 'critical', color: 'B60205', description: 'Critical change requiring maintainer approval' },
{ name: 'requires-maintainer-approval', color: 'D93F0B', description: 'Must be reviewed by maintainer before merge' },
{ name: 'large-contribution', color: 'FBCA04', description: 'PR contains 500+ record changes' },
// Action labels
{ name: 'auto-fix', color: '7057FF', description: 'Assign to Copilot for automated resolution' },
{ name: 'copilot', color: '7057FF', description: 'Assigned to Copilot coding agent' },
// Type labels
{ name: 'data-correction', color: 'D4C5F9', description: 'Correction to existing data' },
{ name: 'data-addition', color: 'C5DEF5', description: 'Request to add new data' },
{ name: 'bug', color: 'D73A4A', description: 'Something is not working' },
{ name: 'enhancement', color: 'A2EEEF', description: 'New feature or request' },
{ name: 'question', color: 'D876E3', description: 'Further information requested' },
{ name: 'documentation', color: '0075CA', description: 'Documentation improvements' },
{ name: 'help-wanted', color: '008672', description: 'Community contribution welcome' },
// Priority labels
{ name: 'priority:high', color: 'B60205', description: 'High priority issue' },
{ name: 'priority:low', color: 'C2E0C6', description: 'Low priority issue' },
];
let created = 0;
let updated = 0;
let skipped = 0;
for (const label of labels) {
try {
// Try to get existing label
try {
const { data: existing } = await github.rest.issues.getLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name,
});
// Update if colour or description differs
if (existing.color !== label.color || existing.description !== label.description) {
await github.rest.issues.updateLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name,
color: label.color,
description: label.description,
});
updated++;
core.info(`Updated: ${label.name}`);
} else {
skipped++;
core.info(`Exists: ${label.name}`);
}
} catch (getErr) {
if (getErr.status === 404) {
// Create new label
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name,
color: label.color,
description: label.description,
});
created++;
core.info(`Created: ${label.name}`);
} else {
throw getErr;
}
}
} catch (err) {
core.warning(`Failed on "${label.name}": ${err.message}`);
}
}
core.info(`\nLabel setup complete: ${created} created, ${updated} updated, ${skipped} unchanged`);