Run validate on pull requests (with approval gate for forks) - #1774
Draft
aatchison wants to merge 1 commit into
Draft
Run validate on pull requests (with approval gate for forks)#1774aatchison wants to merge 1 commit into
aatchison wants to merge 1 commit into
Conversation
`validate.yml` only triggers on `push`, and fork PRs push to the fork rather than to this repo -- so no external contribution has ever been CI-validated before merge. `main` is excluded from the push trigger too, so merging doesn't validate it either; the next workflow to touch the code is deploy-staging, which deploys. PR #1746 (the npm -> pnpm migration) merged an entire build system change with zero checks ever having run against it. Add a `pull_request` trigger. Fork PR runs get no secrets and a read-only GITHUB_TOKEN, and this repo already sets fork-pr-contributor-approval to all_external_contributors, so each run waits on "Approve and run workflows". Every job in this workflow references zero secrets or vars, so there is nothing for untrusted code to reach even inside the sandbox. Also scope the concurrency group per PR / ref. The bare `validate` group is global, so concurrent pushes on unrelated branches cancel each other's checks. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
validate.ymlnow triggers onpull_request(basemain) in addition topush.validategroup.Why?
Fork PRs are never validated today.
validate.ymltriggers only onpush, and a fork PR pushes to the fork, never to this repo — so no run is ever created here. Confirmed on #1746: zero workflow runs for its branch, and zero runs repo-wide inaction_requiredorwaiting. The "Approve and run workflows" button had nothing to act on, because there was no run.mainis excluded from the push trigger as well, so merging doesn't validate either. The next workflow to touch merged code isdeploy-staging.yml, which deploys to stage. Net effect: an external contribution's first real exercise is a staging deployment.#1746 (
npm→pnpm) is the worked example — an entire frontend build-system rewrite, approved by three reviewers, with no check ever having run against it. It also carried a bug wherepnpm run build -- --mode $APP_ENVsilently dropped the mode and would have shipped a bundle with emptyVITE_*values to S3. Caught by hand; CI wouldn't have caught it either, but CI is the layer that should have had a chance.Is it safe to run fork code?
Yes, and this repo is already configured for it:
pull_requestfrom a fork, GitHub withholds every repository secret and forcesGITHUB_TOKENto read-only, regardless of thepermissions:block.fork-pr-contributor-approvalis already set toall_external_contributors, so each fork run waits for a maintainer to click Approve and run workflows. This PR makes that existing setting actually do something.validate.ymlreferences zerosecrets.*and zerovars.*— lint, build, vitest, pytest, nginx config test. There is nothing for untrusted code to reach even inside the sandbox.pull_request, notpull_request_target. The dangerous pattern ispull_request_target+ checking out PR code, which gets secrets and a write token.pr-merged.ymlusespull_request_targetcorrectly and is untouched here.Concurrency fix
A bare group name is global across the repo, so two people pushing to unrelated branches silently cancel each other's checks. Adding a second trigger would have made that worse.
Open question for reviewers
Internal branches with an open PR now get two runs — one from
push, one frompull_request— since the concurrency keys differ by design. Options:pushtrigger, keepingpull_request+pushtomain: no duplicates, but internal branches aren't validated until a PR exists.Left as a draft deliberately — happy to switch to the second shape if that's the team's preference.
Applicable Issues
Follow-up from review of #1746.
🤖 Generated with Claude Code