The rule
All CI runs on the self-hosted VPS runner. GitHub-hosted runners are never used. The repository is private, so every minute on ubuntu-latest (or any other hosted label) is billed; the owner decided on 2026-11-28 that the project pays no GitHub Actions bill. Every job of every workflow under .github/workflows/ therefore says:
runs-on: [self-hosted, vps]
timeout-minutes: 30A job the runner cannot run is disabled (if: false, with a comment that names what the image lacks) and keeps the same runs-on, so enabling it again cannot bring a hosted runner back. It is never moved to a hosted runner, not even for one run.
[test] scripts/ci-runners.test.mjs (in pnpm test) fails on a runs-on that is not exactly [self-hosted, vps] (disabled jobs included), a job without timeout-minutes, services: or container:, a workflow called from another repository, a workflow without a concurrency group, and a preview job that is not limited to pull requests into main. scripts/preview-workflow.test.mjs holds the trust zones.
The runner
The runner is one ephemeral Docker container per job on the owner's VPS, started by vps-runners-agent from the image vps-runner:latest (the private repository CarlosZiegler/vps-runners holds its Dockerfile). Two jobs run at once; each has 8 CPU cores, 16 GB of memory and an 8 GB memory-backed /tmp. A third job waits in the queue. A project made from this template points runs-on at its own runner with the same label, or builds one from that image.
| The image has | The image does not have |
|---|---|
Ubuntu 24.04, git, curl, jq, unzip, build-essential, Python 3 | A Docker daemon: no services:, container: or Docker actions |
Node 24 in the tool cache (actions/setup-node resolves it without download) | PostgreSQL 15 or 18 (the RLS matrix installs them, see below) |
The pinned pnpm (its default store on /cache is not used, see the rules) | Chromium and its system libraries (the e2e job installs them) |
PostgreSQL 16 server binaries on PATH (initdb, pg_ctl, psql) | wrangler, gh (Wrangler comes from the lockfile or its action) |
Passwordless sudo inside the container | Access to the VPS, its private network or other containers |
So a workflow skips pnpm/action-setup: pnpm is already there. It also skips cache: pnpm, for the reason every job has a package store of its own (below).
What each job needs
| Workflow | Job | Runs on | Adds to its own container |
|---|---|---|---|
ci.yml | checks | every pull request | nothing |
ci.yml | rls-matrix | every pull request | PostgreSQL 15 and 18 from apt.postgresql.org |
e2e.yml | web | same-repository pull requests, main | Chromium with its system libraries (--with-deps) |
pr-preview.yml | provision | pull requests into main | nothing (its own package store) |
pr-preview.yml | build | pull requests into main | nothing (its own package store) |
pr-preview.yml | deploy | pull requests into main | the lockfile's Wrangler, under /tmp |
pr-preview.yml | cleanup | closed pull requests into main | nothing (its own package store) |
deploy-prod.yml | prod | push to main | nothing (Wrangler through wrangler-action) |
delete-deploy.yml | delete, reject | manual | nothing (curl) |
emergency-shutdown.yml | toggle, reject | manual | nothing (curl, jq) |
What a job installs with apt lands in its container and is removed with it. Baking PostgreSQL 15 and 18 and the Chromium libraries into the image would save that download on every run; the jobs already skip what they find.
The RLS matrix without Docker. rls-matrix.mjs has one seam, startPostgres(version), with two adapters. docker (the default, for a laptop) starts a postgres:<major> container per server. native starts an initdb/pg_ctl cluster per server in the temp directory from each major's own binaries (PG_BIN_<major>, then /usr/lib/postgresql/<major>/bin, then Homebrew's postgresql@<major>), which is what CI uses:
pnpm --filter @fofo/db test:rls-matrix -- --driver nativeBoth accept the same password over TCP, so the suites are identical. See database.
Previews only for pull requests into main. A preview rehearses the production deploy with the Neon parent branch and domain of main. A pull request into another branch (an integration branch, a stacked pull request) gets none; before this rule it failed after it had created a database branch. cleanup runs when a pull request into main closes: the trusted jobs need an environment that accepts main alone. It first asks GitHub whether the pull request is still closed, removes what was recorded when the preview was provisioned, and then sweeps the previews of other closed pull requests (one retargeted away from main, one whose cleanup failed). See deployment.
Rules for a job
The runner is shared by every private repository of the account, and two jobs run side by side.
- A timeout on every job. A hung job holds one of two slots; the agent only kills it after six hours.
- A
concurrencygroup on every workflow. Pull request workflows cancel the superseded run (cancel-in-progress); deploys and preview operations never cancel, because a run stopped halfway leaves a Worker, a Hyperdrive or a database branch behind. - Nothing outside the workspace and
/tmp. The container, its processes, its ports and its file system disappear with the job. The/cachevolume does not, so no job writes to it: every job that installs setspnpm_config_store_dirto.pnpm-storein its own workspace. The image's shared store would hand what one job wrote, a pull request's code included, to the next job of any repository. The cost is one download per job. - No cache on
main. Apull_request_targetrun executes pull request code and saves caches into the default branch's scope, the one a push tomainrestores from. The e2e job restores its browser cache on pull requests only; jobs that hold a credential use no cache. Everysetup-nodestep setspackage-manager-cache: false. - Secrets in files go to
/tmp, never to the workspace orrunner.temp. Both sit on the/cachevolume while the job runs, where the other running job can read them;/tmpis the job's own. The file lives in a directory the job creates with mode0700and removes in analways()step. Checkouts of jobs that hold deploy secrets usepersist-credentials: false. - No connection string in
GITHUB_ENVor in a job output. The runner keeps both as files underrunner.temp. A value one job hands to the next crosses the job output sealed (scripts/preview-handoff.mjs) and is masked where it is opened. - Local servers stop with the step.
scripts/test-local-postgres.mjs,scripts/e2e-stack.mjsand the RLS matrix stop their clusters on every exit path and keep them under/tmp. - No Docker. A job that needs a database starts a native cluster with
scripts/test-local-postgres.mjs.
Trust zones
A pull request's code is not trusted with anything that outlives its preview. pr-preview.yml runs on pull_request_target, so the workflow file comes from main and a pull request cannot rewrite a job; every job refuses a fork.
| Job | Code it runs | Holds |
|---|---|---|
provision, cleanup | main only | Neon API key, Cloudflare token (environment preview-provision) |
build | the pull request, after main's steps | the preview's own database URLs (environment preview), a read-only GitHub token |
deploy | main only | Cloudflare token, preview secrets (environment preview-provision) |
prod (deploy-prod.yml) | main only | production secrets (environment production) |
- Pull request code never holds the Cloudflare token.
buildmigrates and builds, then hands its output on as one archive.deployruns none of it:scripts/preview-deploy.mjschecks the archive's SHA-256 against the onebuildreported, unpacks it with its own reader (files and directories underserver/andclient/, no link, no path outside) and validates the Wrangler configuration the build wrote. - A preview's name, bindings, variables, routes and triggers come from
main(scripts/preview-worker-config.mjs); a pull request contributes the shape only: entry point, compatibility date and flags, assets, placement, observability, limits. A built configuration that changes a setting, binds or routes anything else, names an account, sets a build command or turns bundling on stops the deploy. Wrangler starts on a configuration and in a directorydeploywrote (it loads.envfrom its working directory), with the token and nothing else of the job's environment. deploywrites the preview comment, from an address it derived.buildhascontents: readonly.buildwrites its configuration withmain's script, kept outside the workspace before the pull request is checked out, so a head of any age builds the same way.- No preview job receives the production database URL. The isolation check compares against the
PRODUCTION_DATABASE_TARGETvariable (postgresql://<host>/<database>, refused with a user or password). provisionhands on only the preview URLs, sealed withPREVIEW_HANDOFF_KEYfor that pull request and run.buildopens them withmain's reader before it checks out the pull request, into a file under/tmp;deployopens them in memory.deployexecutes nothing from the workspace. It fetchesmaininto its own directory under/tmp, installs the lockfile's Wrangler there without install scripts, and downloads the archive there.- Secrets live in environments limited to
main, never in the repository. A repository secret is handed to every job of every workflow, one a pull request or a pushed branch changed included. Each job reads its secrets from its own environment;previewholdsPREVIEW_HANDOFF_KEYalone.pnpm run setup --github-secretspublishes each secret to its environment (SECRET_ENVIRONMENTSinpackages/project-setup-cli/src/secrets.mjs), refuses one that accepts any branch butmainand removes the repository-scoped copy.
A pull request that needs a new binding gets its preview once the binding is on main.
Runner isolation
The rules above are what a job can do by itself. The runner must do the rest, and this is its target layout (set up on the VPS by the owner, not by a workflow):
| Path in the container | Target |
|---|---|
workspace and runner.temp | a directory created for the job, mounted into that container only, deleted with it |
/cache/pnpm-store | not mounted (no job uses it); a shared store only as a read-only mount |
| Node tool cache | part of the image, or mounted read-only |
/tmp | the job's own memory-backed mount, as today, mounted with exec |
Until then two running jobs can read each other's workspace, so the workspace of a job never holds a secret; the runner itself still writes each step's script and each action there. deploy starts a native binary from /tmp and fails in its first step, with the reason, when /tmp is mounted noexec (Docker's default for --tmpfs).
Storage
The runner costs nothing per minute, but three GitHub stores still count against the account's included quota: the e2e report artifact (kept seven days), the preview build archive (kept one day) and the Playwright browser cache (actions/cache, pull requests only). Both are small; lower retention-days before adding another artifact.
Key files
.github/workflows/ci.yml,e2e.yml,pr-preview.yml,deploy-prod.ymlscripts/ci-runners.test.mjs,scripts/preview-workflow.test.mjsscripts/preview.mjs,scripts/preview-handoff.mjs,scripts/preview-build-config.mjs,scripts/preview-deploy.mjspackages/db/scripts/rls-matrix.mjsscripts/test-local-postgres.mjs