From 561308898db379bc4ccb4019e1cdbd319baf73be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20G=2E=20Packer?= Date: Tue, 21 Jun 2022 17:14:25 -0300 Subject: [PATCH] fix(assign-rfc-reviewer):Avoid re-requesting reviews When this action re-requests review from a team, it's PR Review status is set to "Pending", even if it was "Commented"/"Approved"/"Requested Changes" before. The PR Review status shouldn't be automatically changed. Also, there can be false-positive cases for the keywords search. Now, when a false-positive is detected by a team, they can just make a "Comment Review" in the PR. By doing this, the slack bot "Github Scheduled Reminders" shouldn't notify the team about these false-positives. --- .github/actions/assign-rfc-reviewer/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/actions/assign-rfc-reviewer/index.js b/.github/actions/assign-rfc-reviewer/index.js index 78f3b06..7dda0d2 100644 --- a/.github/actions/assign-rfc-reviewer/index.js +++ b/.github/actions/assign-rfc-reviewer/index.js @@ -51,7 +51,19 @@ async function lookForKeywords(octokit, keywords, rfcFileContent) { const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/"); const pull_number = github.context.payload.pull_request.number; + const currentReviewersResponse = await octokit.request( + "GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers", + { + owner, + repo, + pull_number, + } + ); + const currentTeamReviewerSlugs = currentReviewersResponse.data.teams.map((t) => t.slug) + keywords.teams.forEach(async (team) => { + if (currentTeamReviewerSlugs.includes(team.slug)) return; + const keywordFound = team.keywords.some( (keyword) => rfcFileContent.indexOf(keyword) > -1 );