Skip to main content
Policy update (2026-09-09): Environment promotions now use checked fast-forward updates through promote.yml, preserving identical commits without promotion PRs. Release Please targets dev. See knowledge-base/branch-promotions.md for the current procedure; older merge-based examples below are historical.
In one line: Collaborative workflow with four persistent branches (dev → test → pprd → prod), each mapped to a Neon DB branch. Gates get stricter at every stage, no direct pushes to prod, and commits follow Conventional Commits.

Branch Strategy

The platform uses 4 persistent branches, each mapped to an environment: Flow direction: dev → test → pprd → prod Work happens on dev (or short-lived feature branches off dev). Code must pass all CI gates at each stage before being promoted. No direct pushes to prod.

Branch Protection Rules

GitHub Rulesets are the only merge gate: a reviewed pull request into dev that satisfies the required status checks is merged directly. See Engineering Workflow and GitHub Rulesets for the current policy.

Database Per Environment

All environments use Neon DB branches within a single Neon project — no separate paid projects needed.

Prod → pprd Data Replication

Every 24 hours, a GitHub Actions cron job uses the Neon Branch Reset API to sync pprd from prod.
1

Reset the branch

Call the Neon API to reset the pprd branch from prod.
2

Anonymise PII

Run a PII anonymisation script — names, phone numbers, and emails are replaced with fake data.
3

Ready for UAT

pprd is now a clean, realistic copy of prod without real customer data.
This is faster than pg_dump / pg_restore because Neon branching is a near-instant copy-on-write operation at the storage layer.

CI/CD Pipeline

Gates are cumulative — each stage adds checks on top of the previous one.

Commit Conventions

Use Conventional Commits for clean history and automatic changelog generation:

Pre-Commit Hooks

Every git commit automatically runs Biome lint + format on staged files via Husky + lint-staged:
This catches formatting issues and obvious lint errors before they ever reach CI — saving pipeline minutes and avoiding “fix lint” commits.

Secrets Management

Never commit secrets to git. Use .env.local locally (gitignored) and GitHub Actions secrets in CI.

Deployment

  • apps/web and apps/admin: Lambda (ARM64) + CloudFront + S3 per app through sst.aws.Nextjs
  • deploy-aws.yml on push to prod: GitHub OIDC → bunx sst deploy --stage production; when AWS_DOMAINS_LIVE=true, retry both public health endpoints up to 6 times with 15-second waits
  • Recovery: inspect SST/Pulumi logs, stack state, and both applications, then manually deploy a known-good git_ref if needed
  • Cloudflare remains authoritative DNS; SST manages only required validation and alias records

Weekly Backup

Every Sunday at 2 AM UTC, a GitHub Actions workflow:
1

Dump

Run pg_dump against the Neon prod branch.
2

Upload

Upload the compressed dump to Cloudflare R2 (backups/weekly/).
3

Retain

Keep 8 weeks of backups.
4

Heartbeat

Ping the BetterStack heartbeat on success.
Last modified on September 22, 2026