Skip to content

feat: Cloudflare deployment pipeline — wrangler.toml + GitHub Actions#674

Merged
codercatdev merged 2 commits intodevfrom
feat/cf-deploy
Mar 16, 2026
Merged

feat: Cloudflare deployment pipeline — wrangler.toml + GitHub Actions#674
codercatdev merged 2 commits intodevfrom
feat/cf-deploy

Conversation

@codercatdev
Copy link
Copy Markdown
Contributor

Cloudflare Deployment Pipeline

Adds wrangler.toml with dev/production environments and GitHub Actions CI/CD.

wrangler.toml

Replaces wrangler.jsonc with proper TOML format following @softwarearchitect's environment separation doc.

Setting Dev (top-level) Production ([env.production])
Worker name codingcatdev codingcatdev-production
Sanity dataset dev production
D1 database codingcat-auth-dev codingcat-auth
Site URL codingcatdev.workers.dev codingcat.dev

All bindings declared in both environments — CF bindings are non-inheritable.

GitHub Actions

.github/workflows/deploy.yml:

  • Push to dev → build with SANITY_DATASET=devwrangler deploy (dev worker)
  • Push to main → build with SANITY_DATASET=productionwrangler deploy --env production
  • Uses CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID from GitHub secrets (already set by Alex)

astro.config.mjs

Sanity integration now reads dataset from process.env.SANITY_DATASET (with fallback to "production"). This enables per-environment Sanity dataset at build time — the GitHub Actions workflow sets the correct value based on branch.

Before First Deploy

Alex needs to:

  1. Create D1 databases:
    wrangler d1 create codingcat-auth-dev
    wrangler d1 create codingcat-auth
  2. Update database_id values in wrangler.toml with the IDs from step 1
  3. Set secrets on both environments:
    wrangler secret put BETTER_AUTH_SECRET
    wrangler secret put BETTER_AUTH_URL
    wrangler secret put GOOGLE_CLIENT_ID
    wrangler secret put GOOGLE_CLIENT_SECRET
    wrangler secret put SANITY_API_TOKEN
    wrangler secret put SANITY_PREVIEW_SECRET
    # Repeat with --env production for production values

Build

9.5s ✅

Miriad and others added 2 commits March 16, 2026 20:09
Add dev/production environment configuration and CI/CD:

wrangler.toml:
- Dev environment (top-level): codingcatdev worker, dev Sanity dataset,
  codingcat-auth-dev D1 database
- Production environment ([env.production]): codingcatdev-production worker,
  production Sanity dataset, codingcat-auth D1 database
- All bindings declared in BOTH environments (CF bindings are non-inheritable)
- Replaces wrangler.jsonc with proper TOML format

GitHub Actions (.github/workflows/deploy.yml):
- Triggers on push to dev and main branches
- dev branch → build with SANITY_DATASET=dev → wrangler deploy (dev worker)
- main branch → build with SANITY_DATASET=production → wrangler deploy --env production
- Uses CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID from GitHub secrets

astro.config.mjs:
- Sanity dataset now reads from process.env.SANITY_DATASET (falls back to "production")
- Sanity project ID from process.env.SANITY_PROJECT_ID (falls back to hardcoded)
- Enables per-environment Sanity dataset at build time

Also:
- .dev.vars.example for local development secrets
- D1 database IDs are placeholders — Alex needs to create databases and update

Build verified: 9.9s ✅

Co-authored-by: seniordeveloper <seniordeveloper@miriad.systems>
B1: Replace npm ci with pnpm/action-setup + pnpm install --frozen-lockfile.
    Build via pnpm --filter @codingcatdev/web build (respects workspace).
    wrangler deploy still runs from apps/web/ working directory.

I1: Restore global_fetch_strictly_public compatibility flag that was in
    the original wrangler.jsonc. Dropping it unintentionally could cause
    runtime fetch behavior changes.

Build verified: 10.5s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant