Deployment

The Website deploys to Cloudflare Workers with Wrangler. Production deploys happen from the default environment; previews are per-branch versioned uploads.

Production deploy

npm run build
npm run deploy   # wrangler deploy

wrangler deploy uploads dist/worker.js (the esbuild Worker bundle) and the dist/client static assets, using the default [vars] and the API_WORKER Service Binding from wrangler.toml. The Worker then serves swapps.com via the Workers Routes described in Cloudflare Workers.

Environment URL wrangler.toml section
Production https://swapps.com [vars] (default)
Preview https://{alias}-swapps-client.swapps.workers.dev [env.preview.*]
Local dev http://localhost:3000 [env.dev.*]

Preview deployments

npm run preview

This runs scripts/build-with-env.ts preview and then wrangler versions upload --compatibility-date <today>, producing a versioned upload (not a production release) so a build can be validated before promotion.

Per-branch previews (GitHub Actions)

The deploy-preview.yml workflow is a manual (workflow_dispatch) job that takes a branch name and:

  1. Checks out the branch and installs dependencies.
  2. Runs npm run build.
  3. Derives an alias from the branch name (lowercased, non-alphanumeric → -).
  4. Runs npx wrangler versions upload --preview-alias "<alias>".
  5. Emits the preview URL https://<alias>-swapps-client.swapps.workers.dev.

It authenticates with the CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID repository secrets.

Continuous integration

The ci.yml workflow runs on push to master, main, develop, and CU-* branches:

  1. ESLint on changed .ts/.tsx/.js/.jsx files.
  2. Prettier check on changed files.
  3. npm run type-check.
  4. npm run build (build verification).
  5. Route tests (npm run test:routes), plus optional simple tests.

CI runs with test env values (NODE_ENV=test, API_URL=http://localhost:8787, GTM_ID=GTM-TEST).

Other workflows in .github/workflows/ cover Percy visual snapshots (percy-snapshot.yml), Get Swapps E2E (getswapps-e2e.yml), SonarQube (sonarq-build.yml), and ClickUp / website-repo notifications.

Git hooks

Husky enforces quality locally:

  • pre-commitlint-staged (ESLint + Prettier on staged files).
  • pre-push — type-check, route tests, and build.
  • commit-msg — validates the CU-<id> - <type>: <subject> convention.

Worker secrets

Some runtime values are secrets, not [vars], and must be set with wrangler secret put (or in CI) rather than committed:

Secret Purpose
CACHE_API_SECRET Auth for the blog cache-purge webhook (matches WordPress)
CF_ZONE_ID swapps.com zone id for global cache purge
CF_PURGE_TOKEN Scoped Cloudflare token (Zone → Cache Purge)

See Environment setup.

Rollback

Because deploys are versioned uploads, roll back by promoting a previous version via Wrangler / the Cloudflare dashboard (wrangler deployments / wrangler rollback).

Next steps