.github/request-reviews.yml: Only post non-collab message once

Enhances the flow that adds a comment on a PR if a non-collaborator
is in the reviewer list by checking if a comment was previously left
on the PR. If it was for the same set of non-collaborators, another
comment is not created. If a new non-collaborator is discovered, the
message will be left identifying that new user account.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
This commit is contained in:
Michael Kubacki 2024-07-31 18:54:55 -04:00 committed by mergify[bot]
parent 09ad1a0072
commit f617b6ee0e
1 changed files with 33 additions and 23 deletions

View File

@ -221,6 +221,16 @@ def add_reviewers_to_pr(
f"::error title=User is not a Collaborator!::{', '.join(non_collaborators)}"
)
for comment in pr.get_issue_comments():
# If a comment has already been made for these non-collaborators,
# do not make another comment.
if (
comment.user.login == "github-actions[bot]"
and "WARNING: Cannot add some reviewers" in comment.body
and all(u in comment.body for u in non_collaborators)
):
break
else:
repo_admins = [
a.login for a in repo_gh.get_collaborators(permission="admin")
]