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