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            cppcoffee
 37            davidbarsky
 38            davewa
 39            ddoemonn
 40            djsauble
 41            errmayank
 42            fantacell
 43            findrakecil
 44            FloppyDisco
 45            gko
 46            huacnlee
 47            imumesh18
 48            jacobtread
 49            jansol
 50            jeffreyguenther
 51            jenslys
 52            jongretar
 53            lemorage
 54            lnay
 55            marcocondrache
 56            marius851000
 57            mikebronner
 58            ognevny
 59            playdohface
 60            RemcoSmitsDev
 61            romaninsh
 62            Simek
 63            someone13574
 64            sourcefrog
 65            suxiaoshao
 66            Takk8IS
 67            thedadams
 68            tidely
 69            timvermeulen
 70            valentinegb
 71            versecafe
 72            vitallium
 73            warrenjokinen
 74            WhySoBad
 75            ya7010
 76            Zertsov
 77        with:
 78          script: |
 79            const communityChampions = process.env.COMMUNITY_CHAMPIONS
 80              .split('\n')
 81              .map(handle => handle.trim().toLowerCase())
 82              .filter(handle => handle.length > 0);
 83
 84            let author;
 85            if (context.eventName === 'issues') {
 86              author = context.payload.issue.user.login;
 87            } else if (context.eventName === 'pull_request_target') {
 88              author = context.payload.pull_request.user.login;
 89            }
 90
 91            if (!author || !communityChampions.includes(author.toLowerCase())) {
 92              return;
 93            }
 94
 95            const issueNumber = context.payload.issue?.number || context.payload.pull_request?.number;
 96
 97            try {
 98              await github.rest.issues.addLabels({
 99                owner: context.repo.owner,
100                repo: context.repo.repo,
101                issue_number: issueNumber,
102                labels: ['community champion']
103              });
104
105              console.log(`Applied 'community champion' label to #${issueNumber} by ${author}`);
106            } catch (error) {
107              console.error(`Failed to apply label: ${error.message}`);
108            }