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: ubuntu-latest
13 steps:
14 - name: Check if author is a community champion and apply label
15 uses: actions/github-script@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 lnay
56 marcocondrache
57 marius851000
58 mikebronner
59 ognevny
60 PKief
61 playdohface
62 RemcoSmitsDev
63 romaninsh
64 rxptr
65 Simek
66 someone13574
67 sourcefrog
68 suxiaoshao
69 Takk8IS
70 tartarughina
71 thedadams
72 tidely
73 timvermeulen
74 valentinegb
75 versecafe
76 vitallium
77 WhySoBad
78 ya7010
79 Zertsov
80 with:
81 script: |
82 const communityChampions = process.env.COMMUNITY_CHAMPIONS
83 .split('\n')
84 .map(handle => handle.trim().toLowerCase())
85 .filter(handle => handle.length > 0);
86
87 let author;
88 if (context.eventName === 'issues') {
89 author = context.payload.issue.user.login;
90 } else if (context.eventName === 'pull_request_target') {
91 author = context.payload.pull_request.user.login;
92 }
93
94 if (!author || !communityChampions.includes(author.toLowerCase())) {
95 return;
96 }
97
98 const issueNumber = context.payload.issue?.number || context.payload.pull_request?.number;
99
100 try {
101 await github.rest.issues.addLabels({
102 owner: context.repo.owner,
103 repo: context.repo.repo,
104 issue_number: issueNumber,
105 labels: ['community champion']
106 });
107
108 console.log(`Applied 'community champion' label to #${issueNumber} by ${author}`);
109 } catch (error) {
110 console.error(`Failed to apply label: ${error.message}`);
111 }