Skip to content

Commit 3991e92

Browse files
committed
ci: add labels workflow
1 parent dc38201 commit 3991e92

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

.github/workflows/labels-create.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# ---------------------------------------------------------------------------------------
2+
# @parent : github workflow
3+
# @desc : manually activated workflow to create issue labels
4+
# @author : Aetherinox
5+
# @url : https://github.com/Aetherinox
6+
# ---------------------------------------------------------------------------------------
7+
8+
name: "🎫 Labels › Create"
9+
run-name: "🎫 Labels › Create"
10+
11+
# ---------------------------------------------------------------------------------------
12+
# triggers
13+
# ---------------------------------------------------------------------------------------
14+
15+
on:
16+
workflow_dispatch:
17+
18+
# ---------------------------------------------------------------------------------------
19+
# environment variables
20+
# ---------------------------------------------------------------------------------------
21+
22+
env:
23+
ASSIGN_USER: Aetherinox
24+
BOT_NAME_1: AdminServ
25+
BOT_NAME_2: AdminServX
26+
BOT_NAME_DEPENDABOT: dependabot[bot]
27+
LABELS_JSON: |
28+
[
29+
{ "name": "AC ✦ Changes Made", "color": "8F1784", "description": "Requested changes have been made and are pending a re-scan" },
30+
{ "name": "AC ✦ Changes Required", "color": "8F1784", "description": "Requires changes to be made to the package before being accepted" },
31+
{ "name": "AC ✦ Failed", "color": "a61f2d", "description": "Autocheck failed to run through a complete cycle, requires investigation" },
32+
{ "name": "AC ✦ Needs Rebase", "color": "8F1784", "description": "Due to the permissions on the requesting repo, this pull request must be rebased by the author" },
33+
{ "name": "AC ✦ Passed", "color": "146b4a", "description": "Ready to be reviewed" },
34+
{ "name": "AC ✦ Review Required", "color": "8F1784", "description": "PR needs to be reviewed by another person, after the requested changes have been made" },
35+
{ "name": "AC ✦ Security Warning", "color": "761620", "description": "Does not conform to developer policies, or includes potentially dangerous code" },
36+
{ "name": "AC ✦ Skipped Scan", "color": "8F1784", "description": "Author has skipped code scan" },
37+
{ "name": "Status 𐄂 Duplicate", "color": "75536b", "description": "Issue or pull request already exists" },
38+
{ "name": "Status 𐄂 Accepted", "color": "2e7539", "description": "This pull request has been accepted" },
39+
{ "name": "Status 𐄂 Autoclosed", "color": "3E0915", "description": "Originally stale and was autoclosed for no activity" },
40+
{ "name": "Status 𐄂 Denied", "color": "ba4058", "description": "Pull request has been denied" },
41+
{ "name": "Status 𐄂 Locked", "color": "550F45", "description": "Automatically locked by AdminServ for a prolonged period of inactivity" },
42+
{ "name": "Status 𐄂 Need Info", "color": "2E3C4C", "description": "Not enough information to resolve" },
43+
{ "name": "Status 𐄂 No Action", "color": "030406", "description": "Closed without any action being taken" },
44+
{ "name": "Status 𐄂 Pending", "color": "984b12", "description": "Pending pull request" },
45+
{ "name": "Status 𐄂 Released", "color": "1b6626", "description": "Issues or PR has been implemented and is now live" },
46+
{ "name": "Status 𐄂 Reopened", "color": "8a6f14", "description": "A previously closed PR which has been re-opened" },
47+
{ "name": "Status 𐄂 Review", "color": "9e1451", "description": "Currently pending review" },
48+
{ "name": "Status 𐄂 Stale", "color": "928282", "description": "Has not had any activity in over 30 days" },
49+
{ "name": "Type ◦ Bug", "color": "9a2c2c", "description": "Something isn't working" },
50+
{ "name": "Type ◦ Dependency", "color": "243759", "description": "Item is associated to dependency" },
51+
{ "name": "Type ◦ Docs", "color": "0e588d", "description": "Improvements or modifications to docs" },
52+
{ "name": "Type ◦ Feature", "color": "3c4e93", "description": "Feature request" },
53+
{ "name": "Type ◦ Git Action", "color": "030406", "description": "GitHub Action / workflow" },
54+
{ "name": "Type ◦ Pull Request", "color": "8F1784", "description": "Normal pull request" },
55+
{ "name": "Type ◦ Roadmap", "color": "8F1784", "description": "Feature or bug currently planned for implementation" },
56+
{ "name": "⚠ Urgent", "color": "a8740e", "description": "Requires urgent attention" }
57+
]
58+
59+
jobs:
60+
61+
# ---------------------------------------------------------------------------------------
62+
# Verify Existing Labels
63+
# This job will ensure you have labels already created in your repo.
64+
#
65+
# All labels come from the JSON table LABELS_JSON.
66+
# ---------------------------------------------------------------------------------------
67+
68+
issues-labels-create:
69+
name: 🎫 Labels › Create
70+
runs-on: ubuntu-latest
71+
steps:
72+
73+
- name: "✅ Start"
74+
run: |
75+
echo "Assigning labels and assignees"
76+
77+
# ---------------------------------------------------------------------------------------
78+
# checkout
79+
# ---------------------------------------------------------------------------------------
80+
81+
- name: "☑️ Checkout"
82+
uses: actions/checkout@v4
83+
with:
84+
fetch-depth: 0
85+
86+
# ---------------------------------------------------------------------------------------
87+
# Check if repo has labels currently added to issues
88+
# ---------------------------------------------------------------------------------------
89+
90+
- name: 🏷️ Verify Existing Labels
91+
uses: actions/github-script@v7
92+
with:
93+
github-token: ${{ secrets.ADMINSERV_TOKEN_CL }}
94+
script: |
95+
const labels = JSON.parse( process.env.LABELS_JSON );
96+
for ( const label of labels )
97+
{
98+
try
99+
{
100+
await github.rest.issues.createLabel(
101+
{
102+
owner: context.repo.owner,
103+
repo: context.repo.repo,
104+
name: label.name,
105+
description: label.description || '',
106+
color: label.color
107+
});
108+
}
109+
catch ( err )
110+
{
111+
if ( err.status === 422 )
112+
{
113+
console.log( `Label '${label.name}' already exists. Skipping.` );
114+
}
115+
else
116+
{
117+
console.error( `Error creating label '${label.name}': ${err}` );
118+
}
119+
}
120+
}

0 commit comments

Comments
 (0)