community_champion_auto_labeler.yml

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