Repository navigation
ci: preview router changes from Actions instead of Vercel's Git builds - #333
Conversation
Turning off Vercel's Git-triggered previews, which Security asked for before the repository goes public, would leave a change to apps/router with no preview at all. router-pr-preview.yml builds the pull request's router with `vercel build --standalone`, which needs no Vercel login or token, and deploys the output as a coder-docs preview only after a docs-preview reviewer approves, with the Vercel CLI from the base commit's lockfile. The output travels as a tarball because upload-artifact would flatten the function symlinks, and the deploy job refuses an archive with entries outside output/, a .. segment, special files, or a symlink that dangles or leaves the output. Assisted-by: AI
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
DOCS-1512 Build router previews in Actions so Vercel Git previews can be turned off
Turning off Vercel's Git-triggered previews (DOCS-1486, Lisa's condition) also removes the only preview a change to Once this and the docs-site previews (coder/docs-engine#311) are in place, |
Router previewapps/router at b84c29a: https://coder-docs-o479hykzb.coderite.app/docs/ The preview is behind Vercel authentication; sign in with your Coder Vercel account. |
An empty commit so the preview's deploy job waits for a docs-preview reviewer again. Assisted-by: AI
…npacking The router declares Node 24 and coder-docs runs it on Node 24, but the build job installed Node 22, so the function was traced under a different runtime than it runs on. The deploy job listed only entry names before extracting, which hides link targets. It now refuses any hard link or absolute symlink in the listing, so no entry can be written through a link to a path outside the stage; the build stores hard-linked files as copies so a real build has none. Relative symlinks with .. stay allowed: the function bundles use them, and the existing post-extraction check still rejects any that leave the output. Assisted-by: AI
Merge order
Independent of #311. If #321 lands first, this workflow's two
vars.VERCEL_ORG_ID/vars.VERCEL_PROJECT_IDreads move tosecrets.like the rest; I'll rebase. Turning off Vercel's Git previews oncoder-docs(the next step in the Linear issue's parent) waits until this has deployed a preview from a real PR.Summary
Security asked for Vercel's Git-triggered preview deployments to be turned off before docs-engine goes public, but those are the only previews a change to
apps/routergets today. This addsrouter-pr-preview.yml, which previews a pull request's router from GitHub Actions on thecoder-docsproject, so the Git integration can be disconnected without losing anything. It runs on pull requests from this repository that touchapps/router,packages/docs-config,packages/docs-manifest, the root manifests or the workflow itself; forks are skipped.Design
The split is the same as
docs-pr-preview.yml. Thebuildjob checks out the pull request, refuses to run if a Vercel secret is visible to it, and runsvercel build --standalone --target=preview. That needs no Vercel login: the job writescoder-docs's project settings (Next.js, Root Directoryapps/router, Node 24) to.vercel/project.jsonitself with placeholder ids, and setsROUTER_BASE_PATH=/docs, the project's preview value, which the router reads at build time for its redirects.--standalonecopies every dependency into the function folders, so the output doesn't point back into the checkout'snode_modules.The output is tarred before upload because
upload-artifactwould turn the 40 function symlinks Next produces into copies. Thedeployjob is bound todocs-preview, so it waits for a reviewer before it can readVERCEL_TOKEN. It checks out the pull request's base commit, not the pull request, and installs the Vercel CLI from that lockfile. Before unpacking, it rejects archive entries outsideoutput/or with a..segment, and any hard link or absolute symlink, since a plain name listing hides link targets and a later entry could otherwise be written through a link; the build stores hard-linked files as copies (--hard-dereference), so a real build has none. Relative symlinks with..stay allowed, because the function bundles use them. After unpacking, it requiresconfig.jsonand rejects special files and any symlink that dangles or resolves outside the output. It deploys with--prebuilt --target=preview, so production can't change, then sets arouter previewcommit status and keeps one comment on the PR with the/docs/URL.Unlike the docs-site preview,
config.jsoncomes from the build, because a Next.js app's routes are compiled output. The deployment runs the pull request's router code withcoder-docs's preview environment variables, which is what Vercel's Git previews do today; the reviewer gate stays in front of it. A same-repo PR's workflow file is the PR's own copy, so the reviewer is what keeps a modified workflow away from the token; moving deploys toworkflow_runso they runmain's copy is tracked with the same-repo preview decision.The CLI-built preview has no stable branch alias, unlike the Git builds; the PR comment is updated on every push instead. AGENTS.md and the README's project table describe the new workflow, and the root
.gitignoregains.vercel/for local runs of the same build.QA
Nothing to see on the docs site. Before merging, I ran the build step locally with an empty Vercel CLI config (no login), then deployed that output once as a
coder-docspreview the way the deploy job does:https://coder-docs-ntufnc4pd.coderite.app/docs/versions.jsonanswers 200 with the live manifest, and/docs/install/answers 200 with the real page, so the project's runtime variables (Global Config, Blob) reach a prebuilt deployment. It needs a Vercel login.This PR runs the workflow itself, because its paths include the workflow file. In the Checks list, the
router-pr-previewrun's build job should pass and its deploy job should wait for adocs-previewreviewer; once approved, a "Router preview" comment and arouter previewstatus appear, and the link opens the router at/docs/after a Vercel login.Testing
actionlint(with ShellCheck) passes on the new workflow and Oxfmt reports it formatted. The build step was replayed locally exactly as written; the archive holds no entries outsideoutput/, and all 40 symlinks resolve inside it. The workflow runs on this PR too, which exercises the CI path end to end.Review feedback applied: the build job now runs Node 24.22.3, matching the router's
enginesand thenodeVersionit writes for coder-docs (it ran Node 22 before), and the deploy job checks link entries before unpacking as described above. The link check was run against the realrouter-outputartifact from this PR's last CI build: its 40 symlinks are all relative and none is flagged. Against a hand-built archive it flags exactly the hard link and the absolute symlink and passes the relative one.Upstream
No. Repository CI.
Linear: DOCS-1512
🤖 Built with AI assistance.