Skip to content
Early bird + Black Friday · 73% off

Get ZeroDirs for $179 $49

Claim $49 deal

Deploy on git push

After Go live, a push to main builds and publishes. Pick one provider — GitHub Actions (USE_GITHUB_DEPLOY=true) or Workers Builds — since running both lets an old commit overwrite a newer deploy.

  1. Create the deploy tokens and store them.

    Cloudflare dashboard → My Profile → API Tokens → Create Token → Custom. D1_READ_TOKEN goes in .env.prod instead of gh secret; step 2 sends it.

    Secret Scope
    CLOUDFLARE_API_TOKEN Edit Cloudflare Workers
    CLOUDFLARE_D1_WRITE_TOKEN D1 Edit only
    D1_READ_TOKEN D1 Read only — the only one the build itself gets
    Terminal
    gh secret set CLOUDFLARE_API_TOKEN # each reads the value from stdin
    gh secret set CLOUDFLARE_D1_WRITE_TOKEN
  2. Send the build variables and switch deploy.yml on.

    Terminal
    pnpm cf:ci --dry-run
    pnpm cf:ci --enable

    Reads .env.prod (or .env), sends each build key per its # ci: line, sets USE_GITHUB_DEPLOY=true; run it again after adding a build key.

  3. Push to main.

    The workflow runs pnpm check, pnpm test and the build before it deploys.

Custom domain:

  1. Add the domain to your Cloudflare account as a zone.

  2. Workers & Pages → your Worker → Settings → Domains & Routes → Add → Custom domain. pnpm cf:setup does this when site.url is on a zone the account owns.

  3. Set site.url to that domain and deploy again.

Where You should see
Everything at once pnpm cf:doctor every line ok; anything else names the fix
The build ran the Actions run, or Workers Builds → Deployments a green build, about a minute
It read the real database the build log [zerodirs-d1] D1 (remote): N approved listings
It is live https://<your domain>/ the change you pushed
  • trailingSlash: 'always': a URL without one earns a 301 (GET) or 308 (everything else), which Stripe records as a failed delivery. Register the Stripe webhook, the Deploy Hook URL, the checkout redirect and every admin route with the slash.

    https://example.com/api/stripe/webhook/ ← correct
    https://example.com/api/stripe/webhook ← 308, recorded as a delivery failure
  • An approval in /admin/ publishes nothing unless providers.rebuild is set — 'github-dispatch' for Actions, 'deploy-hook' for a Deploy Hook created on Settings → Build.

  • Workers Builds free plan: 3,000 build minutes a month, 20 minutes per build, one concurrent build per account — a second connected project queues builds, approvals included.

  • Rollback: Workers & Pages → your Worker → Deployments → pick the previous one → Rollback. A failed build deploys nothing; the live version keeps serving.

  • site.url is baked in at build time: canonicals, the sitemap, the RSS feeds, the absolute OG image URLs. Build with someone else’s value and your canonicals point at their domain.

  • <name>.workers.dev keeps working and bypasses a zone-level Access policy — turn it off under Domains & Routes if admin routes are behind Cloudflare Access. See Security.