Docs truth-sweep against ground truth (package.json, CI workflows): - npm → pnpm across evergreen docs (pnpm 11.25.0 is the package manager; npx tsx → pnpm exec tsx, npx ts-prune/jscpd → pnpm dlx, npm ci → pnpm install --frozen-lockfile, package-lock.json → pnpm-lock.yaml) - Jest → Vitest in README, CONTRIBUTING, COMMANDS (vitest 4 is installed) - Node claims: README 20+ → 22.13+ (engines) with CI/deploy on 24; deployment.md "Setup Node 20 (npm cache)" → Node 24 (pnpm cache), and the pipeline line now shows `pnpm run verify` as CI actually runs - TypeScript 5.x claims → 6 (typescript ^6.0.3); Next.js 14 → 16 in BLOG_SYSTEM, guides/ARCHITECTURE, AI_BOT_SYSTEM_PROMPT - COMMANDS.md: dropped nonexistent `dev:cms` script; services list fixed to db/meilisearch/listmonk (no redis in compose) - HR_RUNBOOK: `npm run test -- src/…` → `pnpm run test src/…` (pnpm passes args without the `--` separator) Historical records (docs/archive/**, dated audit reports, UPGRADE_PLAN) left as-is — they describe what was true when written. Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
7.3 KiB
RevampIT Deployment Guide
Created: 2024-12-29 Last Updated: 2026-09-04 Summary: Production deploys run via GitHub Actions → Hetzner self-host. Vercel is retired.
Production runs on a self-hosted Next.js standalone build on a Hetzner box
(ubuntu@167.233.22.31), served at https://revampit.orangecat.ch behind
systemd (revampit-app). Vercel is no longer used for production.
There is exactly one production deploy method: push to main. GitHub
Actions does the rest.
The deploy flow
Developer
│ git push origin main
▼
GitHub Actions (.github/workflows/deploy-selfhost.yml)
│ pnpm install --frozen-lockfile → pnpm run verify
│ write .env.selfhost.local (from SELFHOST_ENV secret)
│ set up SSH (from HETZNER_SSH_PRIVATE_KEY secret)
│ bash scripts/selfhost-deploy-evig.sh
▼
Build standalone output in the runner
│
▼
Apply unrecorded scripts/db/migrations/*.sql to PROD Postgres (before activating)
│
▼
rsync release → ubuntu@167.233.22.31:/opt/revampit/releases/<id>
│ swap /opt/revampit/app → release
│ systemctl restart revampit-app
▼
Health gate: GET /api/health AND real page render on http://localhost:4004/
│
├─ pass → live at https://revampit.orangecat.ch
└─ fail → auto-rollback to /opt/revampit/app.previous
concurrency: cancel-in-progress is set on the workflow, so two pushes in quick
succession won't clobber each other — the older run is cancelled and the latest
push wins.
How it works (step by step)
Trigger
Any push to main starts the "Deploy production app" workflow
(.github/workflows/deploy-selfhost.yml). Nothing else deploys to production.
What GitHub Actions runs
- Checkout the pushed commit.
- Setup Node 24 (with pnpm cache).
pnpm install --frozen-lockfile— clean install.pnpm run lint— ESLint. A failure here fails the workflow and nothing is deployed.pnpm run typecheck— TypeScript. Same: failure aborts the deploy.- Write
.env.selfhost.localfrom theSELFHOST_ENVrepo secret (chmod 600). - Setup SSH from the
HETZNER_SSH_PRIVATE_KEYrepo secret, and add the Hetzner host toknown_hosts. - Run
bash scripts/selfhost-deploy-evig.sh— the actual deploy.
If either required secret is missing, the workflow logs a notice and exits cleanly without deploying (see Troubleshooting).
What the deploy script does
scripts/selfhost-deploy-evig.sh:
-
Builds the Next.js standalone output locally in the runner.
-
Applies pending DB migrations to PROD first. Any
scripts/db/migrations/*.sqlnot yet recorded in theschema_migrationstable on the production Hetzner Postgres is applied before the new release is activated. A migration failure aborts the deploy (the running release is left untouched). -
Rsyncs the release to
/opt/revampit/releases/<id>onubuntu@167.233.22.31. -
Swaps the symlink
/opt/revampit/app→ the new release. -
Restarts the service:
systemctl restart revampit-app. -
Health-gates the new release on both:
GET /api/health, and- a real page render on
http://localhost:4004/.
If either check fails, it auto-rolls back to
/opt/revampit/app.previousand restarts, so a bad build never stays live.
Persistent uploads: user uploads live in /opt/revampit/uploads and are
symlinked into each release's public/uploads, so they survive release swaps.
Required GitHub repo secrets
Set these once under Settings → Secrets and variables → Actions → New repository secret:
| Secret | Purpose |
|---|---|
HETZNER_SSH_PRIVATE_KEY |
Private SSH key for ubuntu@167.233.22.31. Used to rsync the release and run remote systemctl commands. |
SELFHOST_ENV |
Full contents of .env.selfhost.local (multiline). Written to disk in the runner so the build/deploy has the production env. |
Without both, the workflow skips the deploy and logs a notice.
To set a secret via the GitHub CLI instead of the dashboard:
gh secret set HETZNER_SSH_PRIVATE_KEY < /path/to/private_key
gh secret set SELFHOST_ENV < /path/to/.env.selfhost.local
Monitoring a deploy
- GitHub Actions tab → "Deploy production app" run. Each step (lint, typecheck, deploy) shows live logs.
- Or from the CLI:
gh run list --workflow=deploy-selfhost.yml gh run watch # follow the latest run - A deploy is only done when the workflow's Deploy step finishes green — that means the health gate passed on the box. Never report a feature as deployed before the run is green.
Manual deploy (in a pinch)
The local .husky/pre-push hook is disabled (exit 0) — CI owns production
deploys. If you must deploy from a developer machine (e.g. Actions is down), and
you have a valid .env.selfhost.local (gitignored) plus SSH access to the box:
pnpm run deploy:selfhost
This runs the same scripts/selfhost-deploy-evig.sh locally: build →
migrate → rsync → restart → health gate → rollback on failure. Prefer pushing to
main whenever possible so lint/typecheck and concurrency control still apply.
Troubleshooting
Workflow fails at the Lint or Type check step
The deploy never started — nothing changed in production. Fix locally and push again:
pnpm run lint
pnpm run typecheck
Workflow skips with a "secrets not set" notice
HETZNER_SSH_PRIVATE_KEY and/or SELFHOST_ENV is missing or empty. Add both
repo secrets (see above) and re-run the workflow.
SSH / "Permission denied" or host key errors in the Deploy step
- The
HETZNER_SSH_PRIVATE_KEYsecret is wrong, truncated, or for the wrong key pair. Re-set it with the correct private key forubuntu@167.233.22.31. - If the box's host key changed, the
ssh-keyscanstep still runs each time, so staleknown_hostsisn't usually the cause — focus on the key value.
Deploy aborts during migrations
A scripts/db/migrations/*.sql failed to apply to the PROD Hetzner Postgres. The
running release is left in place (no swap happened). Read the workflow logs
for the failing SQL, fix the migration, and push again. To apply/inspect
manually: ssh ubuntu@167.233.22.31, read DATABASE_URL from
/opt/revampit/app/.env, and run the .sql against psql "$DATABASE_URL" in a
transaction, then record it in schema_migrations.
Release deployed but auto-rolled back
The health gate failed — either GET /api/health or the real page render on
http://localhost:4004/ didn't succeed, so the script reverted to
/opt/revampit/app.previous. Production is still on the previous good release.
Check the workflow logs and the service:
ssh ubuntu@167.233.22.31
journalctl -u revampit-app -n 100 --no-pager
systemctl status revampit-app
Common causes: a runtime env var missing from SELFHOST_ENV, a component that
throws during SSR on the home page, or a migration that changed schema the new
code didn't expect.
Related
- Workflow:
.github/workflows/deploy-selfhost.yml - Deploy script:
scripts/selfhost-deploy-evig.sh - DB / prod environment notes: project
CLAUDE.md→ "Database Configuration" - GitHub secrets reference:
docs/guides/github-vercel-setup.md(legacy filename; see note at its top)