Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/contributors-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Add Contributors Label

on:
issues:
types: [opened]

pull_request_target:
types: [opened]

jobs:
add-contributor-label:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write

steps:
- name: Add Contributor Label
uses: actions/github-script@v8
with:
script: |
const isPR = !!context.payload.pull_request;
const issueNumber = isPR ? context.payload.pull_request.number : context.payload.issue.number;
const authorAssociation = isPR ? context.payload.pull_request.author_association : context.payload.issue.author_association;

if (authorAssociation === 'CONTRIBUTOR') {
Comment on lines +22 to +26

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Label misses first-time contributors

The workflow only adds the label when author_association is exactly 'CONTRIBUTOR', but GitHub uses values like FIRST_TIME_CONTRIBUTOR/FIRST_TIMER for first-time external contributors. That means new contributors’ PRs/issues won’t get the “contributor” label, which contradicts the stated intent to label contributor PRs/issues. Consider including the first-time values (or explicitly documenting that only repeat contributors are labeled).

Useful? React with 👍 / 👎.

await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: ['contributor']
});
}