Skip to content

Run the two-human-reviewers gate on pull_request instead of pull_request_target - #475

Open
Parth Aggarwal (parth21999) wants to merge 2 commits into
masterfrom
paaggarwal-microsoft-reviewer-gate-on-pull-request
Open

Parth Aggarwal (parth21999) wants to merge 2 commits into
masterfrom
paaggarwal-microsoft-reviewer-gate-on-pull-request

Conversation

@parth21999

@parth21999 Parth Aggarwal (parth21999) commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Why

GitHub starts blocking pull_request_target by default in public repositories on November 2, 2026 (default policy). This moves the two-human-reviewers gate to pull_request and keeps the commit-status design from #449.

Changes

  • In .github/workflows/two-human-reviewers.yml and .github/workflow-templates/two-human-reviewers.caller.yml, the pull_request_target trigger becomes pull_request with the same activity types.
  • Unchanged: the mrbot/two-human-reviewers status, the pull_request_review and workflow_dispatch triggers, the permissions (contents: read, pull-requests: read, statuses: write), and the gate logic.
  • Each file's header comment is now 50 words or fewer, per review. The older design notes it held (why a job rather than a branch rule, judging the head commit, gating any bot, the Dependabot exemption) remain in git history and Require two human reviewers on bot-authored pull requests [Ready] #440–[MrBot][AI] Stop failing the two-human job when it is waiting on a human #452.
  • The workflow_dispatch comment now says a manual run publishes the status to the PR's head commit. The old comment said a manual run doesn't unblock a PR, which was only true of its own check run.
  • The warning printed when the status can't be published now tells a maintainer to publish it with Run workflow and the PR number.

Behaviour under pull_request

  • Same-repo branches get a token that can write, so they publish the status as before, pending included. Every bot-authored PR in the last 12 months came from a same-repo branch. Dependabot runs honour the workflow's permissions key (docs).
  • Fork PRs get a read-only token, so the status isn't published and the PR stays blocked until a maintainer runs the workflow manually with the PR number, again after each push or review. Re-running the fork's own run doesn't help, since it keeps the read-only token. About 10 of ~1,630 PRs across the 12 gated repositories in the last 12 months came from forks.
  • Merge conflicts: pull_request doesn't run while a PR has a merge conflict, which pull_request_target did. This fails safe: the push that resolves the conflict re-runs the gate.
  • Self-edits: a same-repo PR that edits the gate is judged by its own copy from the moment it opens, as it already was for reviews. Code-owner review on .github/workflows/** is the control.

Out of scope

  • The 11 caller repositories keep their pull_request_target stubs until they re-copy the template; rulesets and Actions policies are untouched.
  • Draft [MrBot] Pin reviewer workflow to immutable SHA #468 pins the template's uses: to ea713a3e, which predates this change. If it lands first, the pin needs bumping past this PR's merge commit for callers to get the new warning text.

Validation

  • Both files parse as YAML. Triggers, permissions, env and the run script match master apart from comments, the warning text and the trigger rename, and the run script passes bash -n. The repo validator's .yml check passes.
  • This branch is in this repository, so the pull_request trigger runs on this PR. On head 957df31, run 39729594805 had Statuses: write and published mrbot/two-human-reviewers = success with no "Could not publish" warning. master's copy also ran on pull_request_target and published the same verdict; that stops once this merges.

…est_target

GitHub starts blocking pull_request_target by default in public repositories on
November 2, 2026. Move the gate and the caller template to pull_request with the
same activity types, keeping the commit-status design, the pull_request_review and
workflow_dispatch triggers, the permissions, and the gate logic.

Pull requests from branches in the same repository still get a token that can
write, so they publish the status as before, pending included, and Dependabot's
runs honour the permissions key. A fork's pull request gets a read-only token, so
its status is not published and it stays blocked until a maintainer runs the
workflow manually with its number; that run publishes to the pull request's head
commit. The warning printed when publishing fails now says so.

Rewrite the comments that justified pull_request_target or were stale: a manual
run does unblock a pull request (only its own check run lands on the default
branch), both triggers run the pull request's own copy of the workflow, and the
job no longer fails while waiting.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e7c537a1-1b1b-413e-9943-8d3174d1c5ce
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@parth21999

Copy link
Copy Markdown
Member Author

/azp run Azure-C-Build-Tools-Gate

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@@ -53,9 +66,6 @@ name: Two human reviewers
# otherwise have written and vetted, leaving one human short. A dependency bump has no missing author:
# the change is a version number, and the code it pulls in was never going to be written here. The
# repository's normal review rule is the control that fits it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is too much text. condense to 50 words or less.

# their number; a fork's pull request only by dispatching. Start a dispatch with "Run workflow", since
# re-running one of a fork's runs keeps its read-only token. It runs the default branch's copy with a
# token that can write; its own check run attaches to that branch's commit, but the status it publishes
# goes to the pull request's head commit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

too much text, condense to 50 words or less.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e7c537a1-1b1b-413e-9943-8d3174d1c5ce
@parth21999

Copy link
Copy Markdown
Member Author

/azp run Azure-C-Build-Tools-Gate

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant