Skip to content

Commit

Permalink
ci/request-reviews: request reviewers 1-by-1
Browse files Browse the repository at this point in the history
This is to be able to ignore the odd failure for some users, who are
listed as collaborators, but still fail to be requested properly.
  • Loading branch information
wolfgangwalther committed Jan 4, 2025
1 parent a127a80 commit 2a66936
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions ci/request-reviews/request-reviewers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,16 @@ for user in "${!users[@]}"; do
fi
done

# Turn it into a JSON for the GitHub API call to request PR reviewers
jq -n \
--arg users "${!users[*]}" \
'{
reviewers: $users | split(" "),
}' > "$tmp/reviewers.json"

log "Requesting reviews from: $(<"$reviewersFile")"

if ! response=$(gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/$baseRepo/pulls/$prNumber/requested_reviewers" \
--input "$tmp/reviewers.json"); then
log "Failed to request reviews: $response"
exit 1
fi

log "Successfully requested reviews"
for user in "${!users[@]}"; do
log "Requesting review from: $user"

if ! response=$(jq -n --arg user "$user" '{ reviewers: [ $user ] }' | \
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/$baseRepo/pulls/$prNumber/requested_reviewers" \
--input -); then
log "Failed to request review from $user: $response"
fi
done

0 comments on commit 2a66936

Please sign in to comment.