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