Keep up to date with agpt #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Label Contributor | |
on: | |
issues: | |
types: [opened] | |
pull_request: | |
types: [opened] | |
jobs: | |
add-label: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Add Contributor label to specific users' issues and PRs | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const exemptLabel = 'Contributor'; | |
const exemptUsers = ['ph-ausseil']; // Add usernames here | |
async function isPreviousContributor(username) { | |
const contributors = await github.rest.repos.listContributors({ | |
owner: github.context.repo.owner, | |
repo: github.context.repo.repo | |
}); | |
return contributors.data.some(contributor => contributor.login === username); | |
} | |
async function run() { | |
const isExemptUser = exemptUsers.includes(github.actor); | |
const isContributor = await isPreviousContributor(github.actor); | |
if (isExemptUser || isContributor) { | |
const issueOrPrNumber = (github.context.payload.issue || github.context.payload.pull_request).number; | |
await github.rest.issues.addLabels({ | |
owner: github.context.repo.owner, | |
repo: github.context.repo.repo, | |
issue_number: issueOrPrNumber, | |
labels: [exemptLabel] | |
}); | |
} | |
} | |
run(); |