From 9f97846c67fd80e9e19ed6abe5099e3646bd1316 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Thu, 20 May 2021 23:11:12 +0200 Subject: [PATCH] fix: don't spam welcome comment for first prs --- .github/workflows/first-pull-request.yml | 26 +++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/first-pull-request.yml b/.github/workflows/first-pull-request.yml index 4ed46d44..b46b7645 100644 --- a/.github/workflows/first-pull-request.yml +++ b/.github/workflows/first-pull-request.yml @@ -29,6 +29,25 @@ jobs: return; // Creator is already a contributor. } } + + const body = `Hey ${creator}! Thanks for opening your first pull request in this repo. If you haven't already, make sure to read our [contribution guidelines](https://github.com/react-navigation/react-navigation/blob/main/CONTRIBUTING.md).`; + + const comments = await github.issues.listComments({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + }); + + if (comments.data.some(comment => comment.body === body)) { + return; + } + + await github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body + }); await github.issues.addLabels({ issue_number: context.issue.number, @@ -36,10 +55,3 @@ jobs: repo: context.repo.repo, labels: ['first pull request'], }); - - await github.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `Hey ${creator}! Thanks for opening your first pull request in this repo. If you haven't already, make sure to read our [contribution guidelines](https://github.com/react-navigation/react-navigation/blob/main/CONTRIBUTING.md).` - });