From eb1dbb69090bc49ab1df12c6d6f45aa4f67c41ba Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Fri, 29 Sep 2023 10:13:52 +0100 Subject: [PATCH] update labeler to add label and not remove it --- .github/workflows/label.yml | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 807fb3507b8..4de2203647f 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -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'], + }); + }