Repository navigation
Conversation
… main Docs PR previews have failed since their GitHub secrets were removed. Putting the secrets back would not be safe: docs-pr-preview-deploy.yaml runs on pull_request, which reads workflow files from the pull request, so anyone who can push a branch could rewrite the jobs that hold them. Move the engine, build and deploy jobs into docs-pr-preview-publish.yaml and call it as coder/coder/...@main. A job in a called workflow presents a job_workflow_ref claim naming that file and ref, so a Google Cloud workload identity can trust the file on main and nothing a pull request can edit. The jobs read no GitHub secret: - The docs-engine App key stays in Cloud KMS. The engine job has KMS sign the App JWT and exchanges it for a read token on docs-engine. - The Vercel token is read from Secret Manager in the step that uses it. The caller is untrusted. It passes no inputs, the jobs refuse anything but an open pull request from a branch in this repository, and the static export is now checked against a digest in a job output, as the engine source already was, because another job in the run can replace an artifact. docs/.engine-ref may not name an engine older than the default branch's pin. The deploy passes --target=preview. Cleanup gets the Vercel token the same way. A refused deployment listing now fails the run; the groom used to read it as an empty project and report success. The groom runs daily, and closes of pull requests into a non-default branch are left to it. Both workflows are skipped while DOCS_PREVIEW_WORKLOAD_IDENTITY_PROVIDER is unset, so previews stay off, without a failing check, until the identity exists.
This branch was previously deployed
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.
Summary
Docs PR previews (#30698) have failed on every run since the
DOCS_ENGINE_APP_*andVERCEL_PREVIEW_TOKENsecrets were removed; the last green run was 2026-11-14. This changes where the privileged jobs are defined and where their credentials come from, so previews can be turned back on without handing those credentials to every pull request.Previews stay off until the Google Cloud side exists (see Rollout). Until then both workflows are skipped, so merging this also removes the failing check from every docs PR.
Problem
docs-pr-preview-deploy.yamlruns onpull_request, which reads workflow files from the pull request. Its job split keeps PR content away from the secrets, but anyone who can push a branch can edit the workflow itself and read them. Thedocs-previewenvironment has no branch policy or required reviewers, so an environment secret is no better protected. Moving the App key into KMS does not help on its own if the identity allowed to use the key trusts that environment.Fix
Privileged jobs are read from
main.engine,buildanddeploymove to a new reusable workflow,docs-pr-preview-publish.yaml.docs-pr-preview-deploy.yamlkeeps the trigger and the comment job and calls it ascoder/coder/.github/workflows/docs-pr-preview-publish.yaml@main. A job in a called workflow presents ajob_workflow_refclaim naming that file and ref, so a workload identity can trust the file onmainand nothing a pull request can edit.No GitHub secrets. The docs-engine App key stays in Cloud KMS: the engine job has KMS sign the App JWT, then exchanges it for a token limited to
contents: readoncoder/docs-engine. The Vercel token is read from Secret Manager inside the one step that uses it.The caller is treated as hostile. It passes no inputs; the PR number and commit come from the event. The jobs refuse anything but an open
pull_requestfrom a branch in this repository. The static export now travels as an archive checked against a digest in a job output, as the engine source already was, because another job in the caller's run can replace an artifact. The build job gets noid-tokenpermission, since any job in that file that can request an OIDC token can sign in.Engine pin floor.
docs/.engine-refmust still name a commit on docs-enginemain, and may no longer name one older than the default branch's pin; an older pin builds with the default branch's. The deploy job runs that engine's layout script beside the Vercel token, so an old engine should not be selectable.--target=previewon the deploy, so a preview cannot become the project's production deployment. This is the fix from #32126, which this conflicts with.Cleanup reads the Vercel token the same way. A refused deployment listing now fails the run: the weekly groom read it as an empty project and reported success while every preview stayed up. The groom now runs daily, and closes of pull requests into a non-default branch are left to it, because
pull_request_targetruns the base branch's copy of the file, which the identity refuses.Rollout
Nothing here runs until the following exist. None of it can be done from this repository.
repository_id == 440752086andjob_workflow_refiscoder/coder/.github/workflows/docs-pr-preview-publish.yaml@refs/heads/mainorcoder/coder/.github/workflows/docs-pr-preview-cleanup.yaml@refs/heads/main. The repository condition is required: any repository can call a public reusable workflow, andjob_workflow_refwould still name this file.coder-docs-engine-readerApp, imported into Cloud KMS asRSA_SIGN_PKCS1_2048_SHA256, and a service account that may only sign with it. The old key was a repository secret, so it should be deleted, not imported.DOCS_PREVIEW_WORKLOAD_IDENTITY_PROVIDER,DOCS_PREVIEW_ENGINE_SERVICE_ACCOUNT,DOCS_PREVIEW_DEPLOY_SERVICE_ACCOUNT,DOCS_ENGINE_APP_CLIENT_ID,DOCS_ENGINE_APP_KMS_KEY_VERSIONandDOCS_PREVIEW_VERCEL_TOKEN_SECRET. The header ofdocs-pr-preview-publish.yamlgives their formats. Setting the first one turns previews on.docs-pr-preview-cleanupto delete the previews of pull requests closed since 2026-11-15, which are still being served (for examplepr-31990), and delete the untagged production deployment that ci: deploy docs previews to the preview target only #32126 describes.Verification
These workflows cannot run end to end until they are on
mainand the identity exists, so no real run has exercised them. What was run:run:block except the token revocation, extracted from the YAML and executed against stand-ins for Cloud KMS, GitHub, Secret Manager and Vercel. The KMS path used a real RSA key: the resulting JWT verifies withopenssl dgst -sha256 -verify, and a refused signature, an unset variable or the wrong key each exit without writing a token.mainor a missing commit is refused.test-docs-pr-preview-cleanup.sh(new) runs the cleanup script straight out of the workflow. Its listing case fails against the previous listing code withexit status 0, want nonzero.test-docs-preview-mapper.sh: its three assertions on the workflow layout now read the new files, and two were added (the build job holds no identity; no preview workflow reads a GitHub secret). Each of the five fails when the workflow is changed to break it.actionlint,zizmor, ShellCheck andshfmtreport nothing.Not addressed
docs-engine-sourceartifact holds the private engine's source, and anyone with read access to this public repository can download it for a day after each build. That predates this change.npx vercel@65.11.0still resolves its dependency tree at run time in the job that holds the Vercel token.Note
An AI agent (Xum) wrote this change for @sreya and ran the checks above.