From 45a4277026b6732e318c43ffc5184a985d7bdb26 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Wed, 24 Sep 2025 12:42:01 -0400 Subject: [PATCH] Add community champion auto labeler (#38802) Release Notes: - N/A --- .../community_champion_auto_labeler.yml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/community_champion_auto_labeler.yml diff --git a/.github/workflows/community_champion_auto_labeler.yml b/.github/workflows/community_champion_auto_labeler.yml new file mode 100644 index 0000000000000000000000000000000000000000..c525bf4738f888b5ca84230982ff1f4f5da2db2f --- /dev/null +++ b/.github/workflows/community_champion_auto_labeler.yml @@ -0,0 +1,48 @@ +name: Community Champion Auto Labeler + +on: + issues: + types: [opened] + pull_request_target: + types: [opened] + +jobs: + label_community_champion: + if: github.repository_owner == 'zed-industries' + runs-on: ubuntu-latest + steps: + - name: Check if author is a community champion and apply label + uses: actions/github-script@v7 + with: + script: | + const communityChampionBody = `${{ secrets.COMMUNITY_CHAMPIONS }}`; + + const communityChampions = communityChampionBody + .split('\n') + .map(handle => handle.trim().toLowerCase()); + + let author; + if (context.eventName === 'issues') { + author = context.payload.issue.user.login; + } else if (context.eventName === 'pull_request_target') { + author = context.payload.pull_request.user.login; + } + + if (!author || !communityChampions.includes(author.toLowerCase())) { + return; + } + + const issueNumber = context.payload.issue?.number || context.payload.pull_request?.number; + + try { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueNumber, + labels: ['community champion'] + }); + + console.log(`Applied 'community champion' label to #${issueNumber} by ${author}`); + } catch (error) { + console.error(`Failed to apply label: ${error.message}`); + }