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'], + }); + }