diff options
author | Michael Kubacki <michael.kubacki@microsoft.com> | 2024-07-31 18:54:55 -0400 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-08-05 19:30:26 +0000 |
commit | f617b6ee0eb81853b50fd50ea71dd1b2ceb9b9a5 (patch) | |
tree | 692f22d213e83bf1d6720b8e5fb84b5c0184f6d3 /.github | |
parent | 09ad1a00729d53ba06e7f441eefc6fa364b10059 (diff) | |
download | edk2-f617b6ee0eb81853b50fd50ea71dd1b2ceb9b9a5.zip edk2-f617b6ee0eb81853b50fd50ea71dd1b2ceb9b9a5.tar.gz edk2-f617b6ee0eb81853b50fd50ea71dd1b2ceb9b9a5.tar.bz2 |
.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>
Diffstat (limited to '.github')
-rw-r--r-- | .github/scripts/GitHub.py | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/.github/scripts/GitHub.py b/.github/scripts/GitHub.py index 5db2060..6c755c2 100644 --- a/.github/scripts/GitHub.py +++ b/.github/scripts/GitHub.py @@ -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")
- ]
-
- 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)",
- )
+ 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)",
+ )
# Add any new reviewers to the PR if needed.
if new_pr_reviewers:
|