Skip to content

ci: preview router changes from Actions instead of Vercel's Git builds - #333

Merged
nickvigilante merged 3 commits into
mainfrom
vigilante/docs-1512-router-preview
Nov 12, 2026
Merged

nickvigilante merged 3 commits into
mainfrom
vigilante/docs-1512-router-preview

Conversation

@nickvigilante

@nickvigilante nickvigilante commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Merge order

Independent of #311. If #321 lands first, this workflow's two vars.VERCEL_ORG_ID / vars.VERCEL_PROJECT_ID reads move to secrets. like the rest; I'll rebase. Turning off Vercel's Git previews on coder-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/router gets today. This adds router-pr-preview.yml, which previews a pull request's router from GitHub Actions on the coder-docs project, so the Git integration can be disconnected without losing anything. It runs on pull requests from this repository that touch apps/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. The build job checks out the pull request, refuses to run if a Vercel secret is visible to it, and runs vercel build --standalone --target=preview. That needs no Vercel login: the job writes coder-docs's project settings (Next.js, Root Directory apps/router, Node 24) to .vercel/project.json itself with placeholder ids, and sets ROUTER_BASE_PATH=/docs, the project's preview value, which the router reads at build time for its redirects. --standalone copies every dependency into the function folders, so the output doesn't point back into the checkout's node_modules.

The output is tarred before upload because upload-artifact would turn the 40 function symlinks Next produces into copies. The deploy job is bound to docs-preview, so it waits for a reviewer before it can read VERCEL_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 outside output/ 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 requires config.json and 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 a router preview commit status and keeps one comment on the PR with the /docs/ URL.

Unlike the docs-site preview, config.json comes from the build, because a Next.js app's routes are compiled output. The deployment runs the pull request's router code with coder-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 to workflow_run so they run main'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 .gitignore gains .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-docs preview the way the deploy job does: https://coder-docs-ntufnc4pd.coderite.app/docs/versions.json answers 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-preview run's build job should pass and its deploy job should wait for a docs-preview reviewer; once approved, a "Router preview" comment and a router preview status 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 outside output/, 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 engines and the nodeVersion it 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 real router-output artifact 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.

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
@vercel

vercel Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
coder-docs Ignored Ignored Preview Nov 12, 2026 3:25pm UTC

Request Review

@linear-code

linear-code Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
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 apps/router gets. Replace it with an Actions job that runs vercel build and vercel deploy --prebuilt --target=preview for apps/router on coder-docs, triggered on PRs that touch apps/router, packages/docs-config or packages/docs-manifest, with the same split as docs-pr-preview.yml: build with no token, deploy from main's engine in an environment.

Once this and the docs-site previews (coder/docs-engine#311) are in place, coder-docs is the only project the engine deploys to, and Git can be disconnected from previews without losing anything.

Review in Linear

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Router preview

apps/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
@nickvigilante
nickvigilante marked this pull request as ready for review November 12, 2026 15:03
@nickvigilante
nickvigilante requested a review from a team as a code owner November 12, 2026 15:03
…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
@nickvigilante
nickvigilante merged commit bd3d137 into main Nov 12, 2026
32 checks passed
@nickvigilante
nickvigilante deleted the vigilante/docs-1512-router-preview branch November 12, 2026 16:38

This branch was previously deployed

2 inactive (1 outdated) deployments
docs-preview — b84c29ac Deployed Nov 12, 2026 by nickvigilante via deploy router preview #3
Preview — 91fce81f Deployed Nov 10, 2026 by vercel[bot]
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