Skip to content

Commit 564490a

Browse files
rdimitrovclaude
andcommitted
Filter reviewers to repo collaborators only
Previous behavior pulled every non-bot commit author from the upstream release range and passed them to `gh pr edit --add-reviewer` as a single comma-separated list. GitHub rejects reviewer requests for non-collaborators with 422, and because the API treats the list atomically, one community contributor in the range would fail the entire call and drop all valid reviewers with it. Fix: - Probe each candidate with `gh api repos/<repo>/collaborators/<user>` before adding. 204 -> keep; 404 -> skip. - Emit a separate `skipped` output listing non-collaborator contributors so the PR body can acknowledge them by name ("Other release contributors ... Thanks for the contribution!") without actually requesting review from them. Pre-existing bot-regex filter runs first so we don't waste API calls on [bot] users. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a68f13e commit 564490a

1 file changed

Lines changed: 39 additions & 7 deletions

File tree

.github/workflows/upstream-release-docs.yml

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,21 +367,48 @@ jobs:
367367
REPO: ${{ steps.detect.outputs.repo }}
368368
PREV: ${{ steps.detect.outputs.prev_tag }}
369369
NEW: ${{ steps.detect.outputs.new_tag }}
370+
REVIEW_REPO: ${{ github.repository }}
370371
run: |
371-
# Capture stderr separately so we can surface a missing-compare
372-
# situation in the PR body rather than silently dropping reviewers.
372+
# Get non-bot commit authors in the release range.
373373
if COMPARE=$(gh api "repos/$REPO/compare/$PREV...$NEW" \
374374
--jq '[.commits[].author.login? // empty] | unique | .[]' 2>/dev/null); then
375-
REVIEWERS=$(echo "$COMPARE" |
376-
grep -Ev '(\[bot\]$|^github-actions|^stacklokbot$|^dependabot|^renovate|^copilot)' |
377-
head -5 | paste -sd, -)
378375
echo "compare_ok=true" >> "$GITHUB_OUTPUT"
379376
else
380-
REVIEWERS=""
377+
COMPARE=""
381378
echo "compare_ok=false" >> "$GITHUB_OUTPUT"
382379
fi
380+
381+
# Filter out bot accounts, then further filter to only this
382+
# repo's collaborators. GitHub rejects reviewer requests for
383+
# non-collaborators with 422, which would fail the whole
384+
# `gh pr edit --add-reviewer` call and drop the valid
385+
# reviewers along with the invalid ones. Community
386+
# contributors from the upstream repo often aren't
387+
# collaborators on docs-website; silently skip them rather
388+
# than ping or fail.
389+
CANDIDATES=$(echo "$COMPARE" |
390+
grep -Ev '(\[bot\]$|^github-actions|^stacklokbot$|^dependabot|^renovate|^copilot)' || true)
391+
392+
REVIEWERS=""
393+
SKIPPED=""
394+
while IFS= read -r login; do
395+
[ -z "$login" ] && continue
396+
if gh api "repos/$REVIEW_REPO/collaborators/$login" --silent 2>/dev/null; then
397+
REVIEWERS="${REVIEWERS:+$REVIEWERS,}$login"
398+
else
399+
SKIPPED="${SKIPPED:+$SKIPPED, }$login"
400+
fi
401+
done <<< "$CANDIDATES"
402+
403+
# Cap at 5 to avoid review fatigue.
404+
REVIEWERS=$(echo "$REVIEWERS" | tr ',' '\n' | head -5 | paste -sd, -)
405+
383406
echo "list=$REVIEWERS" >> "$GITHUB_OUTPUT"
407+
echo "skipped=$SKIPPED" >> "$GITHUB_OUTPUT"
384408
echo "Reviewers: ${REVIEWERS:-<none>}"
409+
if [ -n "$SKIPPED" ]; then
410+
echo "Skipped non-collaborator contributors: $SKIPPED"
411+
fi
385412
386413
- name: Read docs_paths hint
387414
id: hints
@@ -570,6 +597,7 @@ jobs:
570597
GAPS_BLOCK: ${{ steps.signals.outputs.gaps_block }}
571598
AUTOGEN_NOTE: ${{ steps.autogen.outputs.note }}
572599
COMPARE_OK: ${{ steps.reviewers.outputs.compare_ok }}
600+
SKIPPED_REVIEWERS: ${{ steps.reviewers.outputs.skipped }}
573601
run: |
574602
START='<!-- upstream-release-docs:start -->'
575603
END='<!-- upstream-release-docs:end -->'
@@ -603,8 +631,12 @@ jobs:
603631
echo "$GAPS_BLOCK"
604632
echo ""
605633
fi
606-
echo "Reviewers below are non-bot commit authors in the release range."
634+
echo "Reviewers below are non-bot commit authors in the release range who are also collaborators on this repo."
607635
echo ""
636+
if [ -n "$SKIPPED_REVIEWERS" ]; then
637+
echo "Other release contributors (not assigned as reviewers because they aren't repo collaborators): $SKIPPED_REVIEWERS. Thanks for the contribution!"
638+
echo ""
639+
fi
608640
echo "$END"
609641
} > /tmp/section.md
610642

0 commit comments

Comments
 (0)