Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

issue-labels.yml

76 lines2.2 KB

1name: Issue Labels
2​
3on:
4 push:
5 branches:
6 - main
7 paths:
8 - .github/ISSUE_TEMPLATE/**
9 - .github/workflows/issue-labels.yml
10 workflow_dispatch:
11​
12permissions: {}
13​
14jobs:
15 sync:
16 name: Sync issue labels
17 runs-on: ubuntu-24.04
18 permissions:
19 issues: write
20 steps:
21 - name: Ensure managed issue labels exist
22 uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
23 with:
24 script: |
25 const managedLabels = [
26 {
27 name: "bug",
28 color: "d73a4a",
29 description: "Something is broken or behaving incorrectly.",
30 },
31 {
32 name: "enhancement",
33 color: "a2eeef",
34 description: "Requested improvement or new capability.",
35 },
36 {
37 name: "needs-triage",
38 color: "fbca04",
39 description: "Issue needs maintainer review and initial categorization.",
40 },
41 ];
42​
43 for (const label of managedLabels) {
44 try {
45 const { data: existing } = await github.rest.issues.getLabel({
46 owner: context.repo.owner,
47 repo: context.repo.repo,
48 name: label.name,
49 });
50​
51 if (
52 existing.color !== label.color ||
53 (existing.description ?? "") !== label.description
54 ) {
55 await github.rest.issues.updateLabel({
56 owner: context.repo.owner,
57 repo: context.repo.repo,
58 name: label.name,
59 color: label.color,
60 description: label.description,
61 });
62 }
63 } catch (error) {
64 if (error.status !== 404) {
65 throw error;
66 }
67​
68 await github.rest.issues.createLabel({
69 owner: context.repo.owner,
70 repo: context.repo.repo,
71 name: label.name,
72 color: label.color,
73 description: label.description,
74 });
75 }
76 }