Skip to content
Closed
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
63 changes: 63 additions & 0 deletions .github/workflows/probe-review-dismissal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# TEMPORARY probe. Not for merge — deleted with its branch once it has run.
# Answers three questions about what GITHUB_TOKEN may do to reviews on a PR
# targeting a PROTECTED branch, which is the case every connector repo is in:
# 1. can github-actions[bot] submit REQUEST_CHANGES? (known yes; baseline)
# 2. can it dismiss a CHANGES_REQUESTED it authored? (the auto-dismiss option)
# 3. can it submit APPROVE? (what judge mode needs)
name: probe-review-dismissal
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: read
pull-requests: write
jobs:
probe:
if: startsWith(github.head_ref, 'felipe/probe-review-dismissal')
runs-on: ubuntu-latest
steps:
- name: Probe review verbs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
SHA: ${{ github.event.pull_request.head.sha }}
shell: bash
run: |
set +e
probe() { # probe <label> <method> <path> [field...]
local label="$1"; shift
local method="$1"; shift
local path="$1"; shift
echo "::group::${label}"
echo "--> ${method} ${path}"
out=$(gh api -X "${method}" "${path}" "$@" 2>&1); rc=$?
echo "exit=${rc}"
echo "${out}" | head -40
echo "::endgroup::"
LAST_OUT="${out}"; LAST_RC="${rc}"
}

probe "1. submit REQUEST_CHANGES" POST "repos/${REPO}/pulls/${PR}/reviews" \
-f commit_id="${SHA}" -f event=REQUEST_CHANGES -f body="probe: request changes"
RID=$(printf '%s' "${LAST_OUT}" | jq -r '.id // empty' 2>/dev/null)
echo "RESULT 1 submit REQUEST_CHANGES: rc=${LAST_RC} review_id=${RID:-none}"

if [ -n "${RID}" ]; then
probe "2. dismiss OWN review ${RID}" PUT \
"repos/${REPO}/pulls/${PR}/reviews/${RID}/dismissals" \
-f message="probe: can the author of a review dismiss it?"
echo "RESULT 2 self-dismiss on protected base: rc=${LAST_RC}"
probe "2b. review state after dismissal" GET \
"repos/${REPO}/pulls/${PR}/reviews/${RID}"
echo "RESULT 2b state=$(printf '%s' "${LAST_OUT}" | jq -r '.state // "?"' 2>/dev/null)"
else
echo "RESULT 2 skipped: no review id from step 1"
fi

probe "3. submit APPROVE" POST "repos/${REPO}/pulls/${PR}/reviews" \
-f commit_id="${SHA}" -f event=APPROVE -f body="probe: approve"
echo "RESULT 3 submit APPROVE: rc=${LAST_RC}"
Comment on lines +58 to +60

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Suggestion (medium confidence): if probe 3 works, github-actions[bot]'s APPROVE stays on the PR, and nothing here dismisses it. If the repo allows Actions to approve PRs, that approval can count toward required reviews on protected main until the PR is closed. Consider dismissing the APPROVE review id right after logging RESULT 3 (this also tells you whether the bot can dismiss an APPROVE as well as a CHANGES_REQUESTED).


probe "4. final review states" GET "repos/${REPO}/pulls/${PR}/reviews"
echo "RESULT 4 states=$(printf '%s' "${LAST_OUT}" | jq -r '[.[]|{id,state,user:.user.login}]|tostring' 2>/dev/null)"
Comment on lines +62 to +63

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Suggestion (low confidence): general-pr-review also runs on this PR and submits reviews as github-actions[bot]. Probe 4's list can therefore mix in that workflow's REQUEST_CHANGES/COMMENT reviews, and a synchronize re-run adds more probe reviews on top. Filter by the review ids this run created (or by body prefix probe:) so RESULT 4 can't be misread.

Loading