From 077007a65827b7c8127458adf2c3661b91fc5545 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 3 Jan 2025 03:24:37 +0100 Subject: [PATCH] ci/request-reviews: Don't request reviews from non-repo-collaborators Fixes this problem for maintainer-based reviews when the maintainer didn't yet accept or missed the automated invite: gh: Reviews may only be requested from collaborators. One or more of the users or teams you specified is not a collaborator of the NixOS/nixpkgs repository. (HTTP 422) --- ci/request-reviews/process-reviewers.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ci/request-reviews/process-reviewers.sh b/ci/request-reviews/process-reviewers.sh index ec929e25b900..52c0dca0b559 100755 --- a/ci/request-reviews/process-reviewers.sh +++ b/ci/request-reviews/process-reviewers.sh @@ -47,6 +47,16 @@ while read -r user; do fi done < "$tmp/already-reviewed-by" +for user in "${!users[@]}"; do + if ! gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "/repos/$baseRepo/collaborators/$user" >&2; then + log "User $user is not a repository collaborator, probably missed the automated invite to the maintainers team (see ), ignoring" + unset 'users[$user]' + fi +done + # Turn it into a JSON for the GitHub API call to request PR reviewers jq -n \ --arg users "${!users[*]}" \