.github/request-reviews.yml: Update PR reviewer exclusion

Updates logic to:

- Not request reviews from reviewers that have already left a review
  on the PR. Previously, the reviewers review (e.g. approval) would
  remain on the PR, but they would be notified on each change to the
  PR. This approach follows the expected notification process for
  requesting reviews which is one time. Maintainers and reviewers can
  set up their own notifications for more granular updates on PR
  activity separately.

- Add the collaborator reviewers if a reviewer(s) is found to not be
  a collaborator. This is an improvement to today's behavior which is
  to not add any reviewers if a single reviewer is not a collaborator
  of the repo.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
This commit is contained in:
Michael Kubacki
2024-07-31 18:51:12 -04:00
committed by mergify[bot]
parent eaf2b82eda
commit e86647decd
2 changed files with 41 additions and 8 deletions

View File

@@ -84,9 +84,28 @@ jobs:
reviewers = GitHub.get_reviewers_for_range(WORKSPACE_PATH, GET_MAINTAINER_LOCAL_PATH, pr_commit_sha, pr_commit_sha)
if not reviewers:
print("::notice title=No Reviewers Found!::No reviewers found for this PR.")
sys.exit(1)
print("::notice title=No New Reviewers Found!::No reviewers found for this PR.")
sys.exit(0)
print(f"::notice title=Reviewer List::Reviewers found for PR {os.environ['PR_NUMBER']}:\n{', '.join(reviewers)}")
print(
f"::notice title=Preliminary Reviewer List::Total reviewer candidates for "
f"PR {os.environ['PR_NUMBER']}: {', '.join(reviewers)}"
)
GitHub.add_reviewers_to_pr(os.environ['GH_TOKEN'], os.environ['ORG_NAME'], os.environ['REPO_NAME'], int(os.environ['PR_NUMBER']), reviewers)
new_reviewers = GitHub.add_reviewers_to_pr(
os.environ["GH_TOKEN"],
os.environ["ORG_NAME"],
os.environ["REPO_NAME"],
int(os.environ["PR_NUMBER"]),
reviewers,
)
if new_reviewers:
print(
f"::notice title=New Reviewers Added::New reviewers requested for PR "
f"{os.environ['PR_NUMBER']}: {', '.join(new_reviewers)}"
)
else:
print(
"::notice title=No New Reviewers Added::No reviewers were found that "
"should be newly requested."
)