Skip to content

Commit

Permalink
update labeler to add label and not remove it (#4158)
Browse files Browse the repository at this point in the history
update gha workflow to ensure 'new contributor' label isn't removed.
this gha wofklow adds a 'new contributor' label to new first time
contributors that open a pr.

used
[chatgpt](https://chat.openai.com/share/fb8500b8-a672-454d-b599-52ce87ad1e9a)
to help corrct gha
  • Loading branch information
mirnawong1 authored Sep 29, 2023
2 parents 24574a9 + 54ad6fa commit 6a3e4c3
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,32 @@ jobs:
- uses: actions/github-script@v6
with:
script: |
const creator = context.payload.sender.login
const creator = context.payload.sender.login;
const opts = github.rest.issues.listForRepo.endpoint.merge({
...context.issue,
creator,
state: 'all'
})
const issues = await github.paginate(opts)
state: 'all',
});
const issues = await github.paginate(opts);
let isAlreadyContributor = false;
for (const issue of issues) {
if (issue.number === context.issue.number) {
continue
continue;
}
if (issue.pull_request) {
return // creator is already a contributor
if (issue.pull_request && issue.user.login === creator) {
isAlreadyContributor = true;
break;
}
}
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['new contributor']
})
if (!isAlreadyContributor) {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['new contributor'],
});
}

0 comments on commit 6a3e4c3

Please sign in to comment.