diff --git a/.github/workflows/labeler-community.yml b/.github/workflows/labeler-community.yml new file mode 100644 index 0000000000..268f4f5ca8 --- /dev/null +++ b/.github/workflows/labeler-community.yml @@ -0,0 +1,37 @@ +name: Label Community Contributors PRs + +on: + pull_request: + types: [opened] + +jobs: + add-community-label: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + + steps: + - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + with: + script: | + // Get the author association from the event + const association = context.payload.pull_request?.author_association || + context.payload.issue?.author_association; + + // Members have associations like: OWNER, MEMBER, COLLABORATOR + // Non-members have: CONTRIBUTOR, FIRST_TIME_CONTRIBUTOR, FIRST_TIMER, NONE + const memberAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR']; + + if (!memberAssociations.includes(association)) { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: ['community'] + }); + + console.log(`Added 'community' label for ${association} contributor`); + } else { + console.log(`Skipped labeling for ${association}`); + }