From 677f90b78a63f73bcbc772f91cbf626327cc6b1d Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Wed, 18 Mar 2026 13:15:37 +0000 Subject: [PATCH] chore: label community PRs on open (#23157) --- .github/workflows/contrib.yaml | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/contrib.yaml b/.github/workflows/contrib.yaml index 85578785c6..bf81ece746 100644 --- a/.github/workflows/contrib.yaml +++ b/.github/workflows/contrib.yaml @@ -23,6 +23,44 @@ permissions: concurrency: pr-${{ github.ref }} jobs: + community-label: + runs-on: ubuntu-latest + permissions: + pull-requests: write + if: >- + ${{ + github.event_name == 'pull_request_target' && + github.event.action == 'opened' && + github.event.pull_request.author_association != 'MEMBER' && + github.event.pull_request.author_association != 'COLLABORATOR' && + github.event.pull_request.author_association != 'OWNER' + }} + steps: + - name: Add community label + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + with: + script: | + const params = { + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + } + + const labels = context.payload.pull_request.labels.map((label) => label.name) + if (labels.includes("community")) { + console.log('PR already has "community" label.') + return + } + + console.log( + 'Adding "community" label for author association "%s".', + context.payload.pull_request.author_association, + ) + await github.rest.issues.addLabels({ + ...params, + labels: ["community"], + }) + cla: runs-on: ubuntu-latest permissions: