Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Deployment Pipeline

This page documents the environments, CI/CD pipeline, and deployment process for Aero2.

Environments

EnvironmentURLDatabasePurpose
Localhttp://localhost:8787Local D1Development
QAhttps://qa.aero2.devaero2-qaStaging and E2E tests
Productionhttps://aero2.devaero2Live

Pull Request Workflow

When you push a branch and open a PR against main, CI runs automatically:

  1. Lint -- Biome linting (npm run lint)
  2. Build -- Compile and bundle (npm run build)
  3. Unit Tests -- Vitest against local D1 (npm test)
  4. Migration Separation -- Fails if PR mixes code and migration files

No deployment happens on PRs. Code is reviewed and merged to main.

Deployment Pipeline

When a PR is merged to main:

merge to main
    |
    v
1. Build & Test
   - Lint (Biome)
   - Build (Vite + Wrangler)
   - Unit tests (Vitest)
    |
    v
2. Deploy to QA
   - npx wrangler deploy --env qa
   - Verify health: GET https://qa.aero2.dev/health
    |
    v
3. E2E & API Tests
   - Playwright tests against live QA
   - API integration tests against live QA
    |
    v
4. Deploy to Production
   - npx wrangler deploy --env production
    |
    v
5. Health Check
   - GET https://aero2.dev/health
   - Auto-rollback on failure

Rollback

If production is broken after a deployment:

npx wrangler rollback --env production

This reverts to the previous Worker version. Note that database migrations cannot be automatically rolled back -- they must be handled separately.

NPM Scripts Reference

ScriptDescription
npm run devStart local development server
npm run buildBuild for production
npm run lintRun Biome linter
npm run lint:fixRun Biome linter with auto-fix
npm testRun unit tests (Vitest)
npm run test:watchRun unit tests in watch mode
npm run test:e2eRun Playwright E2E tests
npm run test:apiRun API integration tests
npm run deploy:qaDeploy to QA (prefer CI)
npm run deploy:prodDeploy to Production (prefer CI)
npm run migrate:qaApply migrations to QA database
npm run migrate:prodApply migrations to Production database
npm run cf-typegenGenerate TypeScript types from bindings

Secrets Management

Cloudflare Secrets (per environment)

Secrets are stored encrypted in Cloudflare and injected into the Worker at runtime:

# QA
wrangler secret put SECRET_NAME --env qa
 
# Production
wrangler secret put SECRET_NAME --env production
Required secrets:
SecretDescription
MASTER_KEYEncryption key for secrets at rest (32+ character random string)
BOOTSTRAP_ADMIN_EMAILFirst user with this verified email gets admin role
CF_API_TOKENCloudflare API token for custom hostname management
GITHUB_CLIENT_IDGitHub OAuth app client ID
GITHUB_CLIENT_SECRETGitHub OAuth app client secret
GOOGLE_CLIENT_IDGoogle OAuth client ID (optional)
GOOGLE_CLIENT_SECRETGoogle OAuth client secret (optional)

CF_ZONE_ID is configured as an environment var in wrangler.json per environment (not as a secret).

GitHub Secrets (for CI/CD)

Set in the GitHub repository under Settings > Secrets and variables > Actions:

SecretDescription
CF_API_TOKENCloudflare API token for deployments
CF_ACCOUNT_IDCloudflare account ID
D1_QA_DATABASE_IDQA D1 database UUID
D1_PROD_DATABASE_IDProduction D1 database UUID

Troubleshooting

CI/CD Failures

# View recent workflow runs
gh run list
 
# View logs for a specific run
gh run view <run-id> --log-failed

Check Environment Health

curl https://qa.aero2.dev/health
curl https://aero2.dev/health

View Live Logs

npx wrangler tail --env qa
npx wrangler tail --env production

Quick Reference

ActionCommand/Process
Start codingnpm run dev
Run tests locallynpm test
Open PRPush branch, CI runs automatically
DeployMerge to main (automatic)
Apply migrationnpm run migrate:qa then npm run migrate:prod
Rollback productionnpx wrangler rollback --env production
Add secretwrangler secret put NAME --env ENV
View logsnpx wrangler tail --env ENV