Skip to content

Commit

Permalink
ci/request-reviews: Don't request reviews from users not part of the org
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
infinisil committed Jan 3, 2025
1 parent 3c48db1 commit fd82e60
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ci/request-reviews/process-reviewers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ baseRepo=$1
prNumber=$2
prAuthor=$3

org=${baseRepo%%/*}

tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' exit

declare -A users=()
while read -r handle; do
while read -r handle && [[ -n "$handle" ]]; do
users[$handle]=
done

Expand All @@ -47,6 +49,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" \
"/orgs/$org/members/$user" >&2; then
log "User $user is not part of the $org org, probably missed the automated invite (see https://github.com/NixOS/nixpkgs/issues/234293), 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[*]}" \
Expand Down

0 comments on commit fd82e60

Please sign in to comment.