1name: Community Champion Auto Labeler
2
3on:
4 issues:
5 types: [opened]
6 pull_request_target:
7 types: [opened]
8
9jobs:
10 label_community_champion:
11 if: github.repository_owner == 'zed-industries'
12 runs-on: namespace-profile-2x4-ubuntu-2404
13 steps:
14 - name: Check if author is a community champion and apply label
15 uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
16 env:
17 COMMUNITY_CHAMPIONS: |
18 0x2CA
19 5brian
20 5herlocked
21 abdelq
22 afgomez
23 AidanV
24 akbxr
25 AlvaroParker
26 amtoaer
27 artemevsevev
28 bajrangCoder
29 bcomnes
30 Be-ing
31 blopker
32 bnjjj
33 bobbymannino
34 CharlesChen0823
35 chbk
36 davewa
37 davidbarsky
38 ddoemonn
39 djsauble
40 errmayank
41 fantacell
42 fdncred
43 findrakecil
44 FloppyDisco
45 gko
46 huacnlee
47 imumesh18
48 injust
49 jacobtread
50 jansol
51 jeffreyguenther
52 jenslys
53 jongretar
54 lemorage
55 lingyaochu
56 lnay
57 marcocondrache
58 marius851000
59 mikebronner
60 ognevny
61 PKief
62 playdohface
63 RemcoSmitsDev
64 rgbkrk
65 romaninsh
66 rxptr
67 Simek
68 someone13574
69 sourcefrog
70 suxiaoshao
71 Takk8IS
72 tartarughina
73 thedadams
74 tidely
75 timvermeulen
76 valentinegb
77 versecafe
78 vitallium
79 WhySoBad
80 ya7010
81 Zertsov
82 with:
83 script: |
84 const communityChampions = process.env.COMMUNITY_CHAMPIONS
85 .split('\n')
86 .map(handle => handle.trim().toLowerCase())
87 .filter(handle => handle.length > 0);
88
89 let author;
90 if (context.eventName === 'issues') {
91 author = context.payload.issue.user.login;
92 } else if (context.eventName === 'pull_request_target') {
93 author = context.payload.pull_request.user.login;
94 }
95
96 if (!author || !communityChampions.includes(author.toLowerCase())) {
97 return;
98 }
99
100 const issueNumber = context.payload.issue?.number || context.payload.pull_request?.number;
101
102 try {
103 await github.rest.issues.addLabels({
104 owner: context.repo.owner,
105 repo: context.repo.repo,
106 issue_number: issueNumber,
107 labels: ['community champion']
108 });
109
110 console.log(`Applied 'community champion' label to #${issueNumber} by ${author}`);
111 } catch (error) {
112 console.error(`Failed to apply label: ${error.message}`);
113 }