Skip to content

Automated Testing: Update review routing workflow to use GitHub App - #87118

Open
aduth wants to merge 6 commits into
trunkfrom
update/review-routing-github-app
Open

aduth wants to merge 6 commits into
trunkfrom
update/review-routing-github-app

Conversation

@aduth

@aduth aduth commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

What?

Updates the review-routing.yml GitHub Actions workflow to use a token generated using a dedicated "Pull Request Review Router" GitHub App created under the WordPress organization.

In doing so, it updates reviewers for design system review routing configurations from @ciampo and myself to the @WordPress/gutenberg-components team.

Slack discussion: https://wordpress.slack.com/archives/C08D0Q6BHNY/p1794420103676799

Why?

This has a few notable benefits and is a follow-up action item from #86682:

  • Support for teams: GITHUB_TOKEN can't read organization teams, so it can't assign a team as a reviewer. These initial set of review routes were designed with @WordPress/gutenberg-components in mind, but Automated Testing: Support multiple reviewers in review routing #86682 only added a couple individuals since we can't automate team requests. Teams are a better way to distribute ownership and centrally manage membership, and avoids the need for code changes when changing participation.
  • Clarity: Rather than requested reviews coming mysteriously from "github-actions (bot)" (example), the request should now show as coming from "Pull Request Review Router", which should make it clearer why the review was requested.
  • Security: Rather than inherit all of the scopes of GITHUB_TOKEN, we can constrain the app to the specific scopes it needs for reading the pull request and teams, and assigning reviewers.
  • Cross-project adoption: If we want to adopt the review routing in WordPress projects other than just Gutenberg, a GitHub App is the logical way to approach this, where the app can be installed to individual repositories. This will require further work to move the current workflow logic into the app if we want to pursue it, but we'll need the app in any case.

How?

Uses GitHub's official actions/create-github-app-token action, following documented instructions for creating a token with specific permissions, and following a similar approach already used for plugin releases.

Testing Instructions

The pull request includes a few temporary commits to help demonstrate this as working.

  • In 8f3180b, review-routing-demo.yml is a temporary workflow which is identical to review-routing.yml except it uses the pull_request event so that it runs in the context of this pull request (pull_request_target runs in trunk).
  • In 34e1e55, the threshold of one of the existing rules is artificially lowered to force a review request.

With these changes, we should hopefully see @WordPress/gutenberg-components requested as reviewers of this pull request.

Use of AI Tools

Researched and implemented in coordination with Claude Code + Opus 5.5.

@aduth
aduth requested a review from desrosj as a code owner November 19, 2026 19:45
@aduth aduth added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Nov 19, 2026
Copilot AI balanced review requested due to automatic review settings November 19, 2026 19:45
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: simison <simison@git.wordpress.org>
Co-authored-by: desrosj <desrosj@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@pull-request-review-router
pull-request-review-router Bot requested a review from a team November 19, 2026 19:46
@aduth

aduth commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

It appears to be working!

image

I'll revert the temporary commits so this'll be in a mergeable state.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The temporary 0.01 threshold causes production review requests at just 1% relevance, while the demo workflow fails on fork PRs without the API key and duplicates production jobs on same-repository PRs.

1 open issue
What changed in this PR

Updates review routing to use a dedicated GitHub App, enabling team review requests and clearer attribution instead of requests from github-actions.

Changes:

  • Generates a scoped App token for requesting reviews.
  • Routes all nine design-system rules to WordPress/gutenberg-components.
  • Adds a temporary demonstration workflow and lowers the tooling rule’s threshold for testing.
File Description
.github/​workflows/​review-routing.yml Uses a scoped GitHub App token for review requests.
.github/​workflows/​review-routing-demo.yml Adds a temporary pull_request demonstration workflow.
.github/​review-routing/​design-system-tooling.md Assigns the team and temporarily lowers the threshold.
.github/​review-routing/​design-system-tokens.md Routes token reviews to the team.
.github/​review-routing/​design-system-style-sync.md Routes style-sync reviews to the team.
.github/​review-routing/​design-system-patterns.md Routes pattern reviews to the team.
.github/​review-routing/​design-system-migration.md Routes migration reviews to the team.
.github/​review-routing/​design-system-maintenance.md Routes maintenance reviews to the team.
.github/​review-routing/​design-system-docs.md Routes documentation reviews to the team.
.github/​review-routing/​design-system-bespoke-ui.md Routes bespoke UI reviews to the team.
.github/​review-routing/​design-system-api.md Routes API reviews to the team.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the GitHub App review-routing change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@simison

simison commented Nov 20, 2026

Copy link
Copy Markdown
Member

Security: Rather than inherit all of the scopes of GITHUB_TOKEN, we can constrain the app to the specific scopes it needs for reading the pull request and teams, and assigning reviewers.

Assuming yes but asking in case;

  • Above you're saying the token is scoped only to actions this tool needs, and nothing else extra 👍
  • Forks I see are already not running & are protected from secret fishing 👍
  • Is the app/secret limited to trunk env only? That way compromised account with write access can't just read it from branches, if I understand GitHub docs right; not very experienced with Actions…

@aduth

aduth commented Nov 20, 2026

Copy link
Copy Markdown
Member Author
  • Is the app/secret limited to trunk env only? That way compromised account with write access can't just read it from branches, if I understand GitHub docs right; not very experienced with Actions…

It is complicated! But it's also good to ask these clarifying questions around security:

  • For someone without write access (i.e. working from a fork), the main workflow uses pull_request_target, so it operates from trunk. That means that even if someone tried reading a token from their branch, the workflow wouldn't apply anything from their proposed changes. That's also why it's important that we're cautious around what we use of a pull request to use in the review routing.
  • For someone with write access (i.e. working within the repository), they would have the ability to read the token if they used it in a workflow that applies to their pull request. This is essentially what I did in the demonstration commit 8f3180b .

This is the default behavior from GitHub, and we operate with a certain level of trust that those with write access can use these values. GitHub's default GITHUB_TOKEN already works this way, and has more permissions than this token. Could we lock it down any more? Maybe. In the original Slack discussion, I wondered if using an environment secret instead of a repository secret would allow us to restrict the secret to trunk, and if pull_request_target is only run in the context of trunk, it could have that secret while other branches would not have it. Thus effectively preventing reads except for something that actually lands in trunk. @desrosj mentioned this not having any effect, but I'm not sure I followed his rationale there.

@simison

simison commented Nov 24, 2026

Copy link
Copy Markdown
Member

To me it seems like env secrets would still be worth exploring but I'm no expert on Actions setup at all. I do trust the committers, but not the people trying to target them with attacks so good to be a bit paranoid when crafting these configs. :-) Most importantly NPM releases are fairly restricted to smaller group of people than just committer access.

@desrosj

desrosj commented Nov 25, 2026

Copy link
Copy Markdown
Member

@desrosj mentioned this not having any effect, but I'm not sure I followed his rationale there

My main concern was that runs triggered by pull_request_target always use the workflow found in the trunk, but they use the code from the HEAD branch. Mainly because the npm run --silent --workspace @wordpress/review-routing-tools route -- --pr "$PR_NUMBER" --repo "$REPO" --json-file "$RUNNER_TEMP/decisions.json" command would potentially use code from the PR.

However, I had missed the fact that the actions/checkout action will now not use the HEAD branch unless the allow-unsafe-pr-checkout input is set.

I've gone and created the Review Routing environment and set the private key and application ID into the same secret and variable names as the general repository ones that I had originally added (which I've left in place for now).

This branch has not been deployed

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

Labels

[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants