Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/router-pr-preview.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Previews a docs-engine pull request's apps/router as a login-protected
# preview deployment of the coder-docs Vercel project, so router changes keep
# a preview once Vercel's Git-triggered previews are turned off.
# preview deployment of the coder-docs Vercel project. Vercel's own Git builds
# run for main only (apps/router/vercel.json), so this is a router change's
# only preview.
#
# Same split as docs-pr-preview.yml: `build` compiles the pull request's code
# with no Vercel secret and no Vercel login (`vercel build --standalone` needs
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Read [README.md](README.md) and [ARCHITECTURE.md](ARCHITECTURE.md) first for wha
- Stylelint checks the CSS in `packages/docs-theme` as part of that package's `lint` script, with `stylelint-config-recommended` only; formatting stays with Oxfmt, so add no Stylelint style rules.
- For local dev against the real corpus, run `pnpm dev` in `apps/docs` with `DOCS_REPO` pointing at a `coder/coder` checkout. Without it, a small fixture corpus is used.
- Stop a dev server by its port (`kill $(lsof -ti tcp:<port>)`). Never use `pkill -f 'next dev'`, because other sessions run dev servers on the same machine.
- Previews are behind Vercel SSO. Vercel builds only `apps/router`: each branch that changes it gets a stable alias on the `coder-docs` project, built from the branch name with `/` replaced by `-`, which the Vercel bot comment on the PR links. A docs-site change is previewed by running `docs-pr-preview.yml` on the branch, which deploys a prebuilt preview to `coder-docs` and prints its URL.
- A pull request that changes `apps/router`, `docs-config` or `docs-manifest` also gets a router preview from `router-pr-preview.yml`: it builds with `vercel build --standalone` and no Vercel credentials, and deploys once a `docs-preview` reviewer approves, then links the URL in a comment and a `router preview` status. It replaces the Vercel Git previews when those are turned off. The build writes coder-docs's project settings itself, so keep them in step with the Vercel project.
- Previews are behind Vercel SSO. Vercel builds `apps/router` from Git on `main` only, for production; `git.deploymentEnabled` in `apps/router/vercel.json` turns its Git builds off for every other branch, so a pull request gets no Vercel bot preview. A docs-site change is previewed by running `docs-pr-preview.yml` on the branch, which deploys a prebuilt preview to `coder-docs` and prints its URL.
- A pull request that changes `apps/router`, `docs-config` or `docs-manifest` also gets a router preview from `router-pr-preview.yml`: it builds with `vercel build --standalone` and no Vercel credentials, and deploys once a `docs-preview` reviewer approves, then links the URL in a comment and a `router preview` status. It replaces the Vercel Git previews, which are off for every branch but `main`. The build writes coder-docs's project settings itself, so keep them in step with the Vercel project.

## Code

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The docs run on two Vercel projects on the `codercom` team.

| Project | Builds | Serves | Previews |
| ----------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- |
| `coder-docs` | `apps/router` from Git (Root Directory `apps/router`), with `ROUTER_BASE_PATH=/docs` and `DOCS_ANALYTICS=1` | `coder-docs.coderite.app/docs`, from its own manifest and archive stores, behind coder.com's `/docs` rewrite | Behind Vercel login: router previews from Git and from `router-pr-preview.yml`, and docs-site previews prebuilt by `docs-pr-preview.yml` |
| `coder-docs` | `apps/router` from Git on `main` only (Root Directory `apps/router`), with `ROUTER_BASE_PATH=/docs` and `DOCS_ANALYTICS=1` | `coder-docs.coderite.app/docs`, from its own manifest and archive stores, behind coder.com's `/docs` rewrite | Behind Vercel login: router previews from `router-pr-preview.yml`, and docs-site previews prebuilt by `docs-pr-preview.yml` |
| `coder-docs-pr-preview` | Nothing from this repository; coder/coder's own workflows deploy prebuilt output | No production site | Public coder/coder pull request previews only |

The retired `/beta-docs` site's project, `coder-docs-router`, is deleted after this repository stops referring to it; see "Retiring the beta site" in `apps/docs/README.md`.
Expand Down
6 changes: 6 additions & 0 deletions apps/router/lib/vercel-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ type HeaderRule = { source: string; headers: { key: string; value: string }[] };

const config = JSON.parse(readFileSync(new URL("../vercel.json", import.meta.url), "utf8")) as {
headers: HeaderRule[];
git?: { deploymentEnabled?: boolean | Record<string, boolean> };
};

test("Vercel builds the router from Git for main only", () => {
// Every other branch is previewed by router-pr-preview.yml, behind a reviewer.
assert.deepEqual(config.git?.deploymentEnabled, { "**": false, main: true });
});

test("the router's global header rule carries the browser security headers", () => {
const global = config.headers.find((rule) => rule.source === "/(.*)");
assert.ok(global, "vercel.json has no rule for every path");
Expand Down
3 changes: 3 additions & 0 deletions apps/router/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"installCommand": "pnpm install --frozen-lockfile",
"buildCommand": "cd ../.. && pnpm turbo run build --filter=@coder/docs-router --cache=local:rw,remote:$([ \"$VERCEL_ENV\" = production ] && echo rw || echo r)",
"ignoreCommand": "git diff --quiet HEAD^ HEAD -- :/apps/router :/packages :/package.json :/pnpm-lock.yaml :/pnpm-workspace.yaml :/turbo.json || exit 1",
"git": {
"deploymentEnabled": { "**": false, "main": true }
},
"headers": [
{
"source": "/(.*)",
Expand Down
Loading