Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions .github/workflows/dependabot_review_request_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ jobs:
REVIEWER: Pigbibi
run: |
set -euo pipefail
latest_review_request_actor() {
gh api --paginate \
"repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/timeline?per_page=100" |
jq -sr --arg reviewer "${REVIEWER}" \
'[.[][] | select(.event == "review_requested" and .requested_reviewer.login == $reviewer)][-1].actor.login // ""'
}

review_requests="$(gh pr view "${PR_NUMBER}" \
--repo "${GITHUB_REPOSITORY}" \
--json reviewRequests \
Expand All @@ -39,9 +46,7 @@ jobs:
exit 0
fi

latest_request_actor="$(gh api \
"repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/timeline?per_page=100" \
--jq '[.[] | select(.event == "review_requested" and .requested_reviewer.login == "Pigbibi")][-1].actor.login // ""')"
latest_request_actor="$(latest_review_request_actor)"
case "${latest_request_actor}" in
'dependabot[bot]'|'app/dependabot') ;;
*)
Expand All @@ -53,4 +58,16 @@ jobs:
gh api --method DELETE \
"repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/requested_reviewers" \
-f "reviewers[]=${REVIEWER}"
echo "Dismissed Dependabot review request for ${REVIEWER}." >> "${GITHUB_STEP_SUMMARY}"

latest_request_actor="$(latest_review_request_actor)"
case "${latest_request_actor}" in
'dependabot[bot]'|'app/dependabot')
echo "Dismissed Dependabot review request for ${REVIEWER}." >> "${GITHUB_STEP_SUMMARY}"
;;
*)
gh api --method POST \
"repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/requested_reviewers" \
-f "reviewers[]=${REVIEWER}"
Comment on lines +68 to +70

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid restoring a subsequently removed review request

If a maintainer removes Pigbibi's review request after the second timeline read but before this POST, the most recent review_requested event still identifies that maintainer, so this branch recreates the request they intentionally canceled. The cleanup workflow should also account for a later review_request_removed event (or re-check the current review-request state) before restoring it.

Useful? React with 👍 / 👎.

echo "Restored review request made by ${latest_request_actor:-<unknown>}." >> "${GITHUB_STEP_SUMMARY}"
;;
esac
Loading