mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
.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:
parent
09ad1a0072
commit
f617b6ee0e
56
.github/scripts/GitHub.py
vendored
56
.github/scripts/GitHub.py
vendored
@ -221,30 +221,40 @@ def add_reviewers_to_pr(
|
||||
f"::error title=User is not a Collaborator!::{', '.join(non_collaborators)}"
|
||||
)
|
||||
|
||||
repo_admins = [
|
||||
a.login for a in repo_gh.get_collaborators(permission="admin")
|
||||
]
|
||||
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")
|
||||
]
|
||||
|
||||
leave_pr_comment(
|
||||
token,
|
||||
owner,
|
||||
repo,
|
||||
pr_number,
|
||||
f"⚠ **WARNING: Cannot add some reviewers**: A user "
|
||||
f"specified as a reviewer for this PR is not a collaborator "
|
||||
f"of the repository. Please add them as a collaborator to "
|
||||
f"the repository so they can be requested in the future.\n\n"
|
||||
f"Non-collaborators requested:\n"
|
||||
f"{'\n'.join([f'- @{c}' for c in non_collaborators])}"
|
||||
f"\n\nAttn Admins:\n"
|
||||
f"{'\n'.join([f'- @{a}' for a in repo_admins])}\n---\n"
|
||||
f"**Admin Instructions:**\n"
|
||||
f"- Add the non-collaborators as collaborators to the "
|
||||
f"appropriate team(s) listed in "
|
||||
f"[teams](https://github.com/orgs/tianocore/teams)\n"
|
||||
f"- If they are no longer needed as reviewers, remove them "
|
||||
f"from [`Maintainers.txt`](https://github.com/tianocore/edk2/blob/HEAD/Maintainers.txt)",
|
||||
)
|
||||
leave_pr_comment(
|
||||
token,
|
||||
owner,
|
||||
repo,
|
||||
pr_number,
|
||||
f"⚠ **WARNING: Cannot add some reviewers**: A user "
|
||||
f"specified as a reviewer for this PR is not a collaborator "
|
||||
f"of the repository. Please add them as a collaborator to "
|
||||
f"the repository so they can be requested in the future.\n\n"
|
||||
f"Non-collaborators requested:\n"
|
||||
f"{'\n'.join([f'- @{c}' for c in non_collaborators])}"
|
||||
f"\n\nAttn Admins:\n"
|
||||
f"{'\n'.join([f'- @{a}' for a in repo_admins])}\n---\n"
|
||||
f"**Admin Instructions:**\n"
|
||||
f"- Add the non-collaborators as collaborators to the "
|
||||
f"appropriate team(s) listed in "
|
||||
f"[teams](https://github.com/orgs/tianocore/teams)\n"
|
||||
f"- If they are no longer needed as reviewers, remove them "
|
||||
f"from [`Maintainers.txt`](https://github.com/tianocore/edk2/blob/HEAD/Maintainers.txt)",
|
||||
)
|
||||
|
||||
# Add any new reviewers to the PR if needed.
|
||||
if new_pr_reviewers:
|
||||
|
Loading…
x
Reference in New Issue
Block a user