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