chore(github): add label to community contributed PRs (#9009)

This commit is contained in:
Andoni Alonso
2025-10-27 14:48:27 +01:00
committed by GitHub
parent df10bc0c4c
commit c3694fdc5b
+37
View File
@@ -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}`);
}