Skip to content

Deployment

PageZERO is built specifically for Cloudflare’s infrastructure, leveraging Cloudflare Workers for compute and Cloudflare D1 for database storage.

The deployment process involves setting up D1 databases and deploying your application as Cloudflare Workers. You can deploy manually or set up automated deployments through a GitHub Actions CI/CD pipeline.

  1. Create a Cloudflare account - sign up at dash.cloudflare.com if you don’t have one yet.

  2. Login to Cloudflare - in your project root directory, authenticate via the wrangler CLI:

    Terminal window
    bunx wrangler login
  3. Reset your wrangler.json config - initialise the config for your project:

    Terminal window
    bun setup:wrangler
  4. Deploy your app - deploy for preview and production environments:

    Terminal window
    bun run deploy:preview
    Terminal window
    bun run deploy:production
  5. Migrate your database - run migrations for preview and production environments:

    Terminal window
    bun run db:migrate --env preview --remote
    Terminal window
    bun run db:migrate --env production --remote
  6. Your app is now ready! 🎉 - with its core functionality.

    To enable additional features such as authentication, email delivery, and payments, follow the setup sections in the Authentication, E-mail, and Payments documentation.

Automatic deployment happens through the GitHub Actions CI/CD pipeline. Once the pipeline is set up, every merge to the main branch will automatically trigger deployment to Cloudflare Workers and a database migration for Cloudflare D1. Additionally, every PR will trigger a preview deployment, allowing you to access a specific version of your app for each PR.

  1. Complete the first deployment - follow the First deployment steps above to deploy your app and run database migrations.

  2. Login to GitHub - authenticate via the gh CLI:

    Terminal window
    gh auth login
  3. Create a GitHub repository - create a private repo and push all changes:

    Terminal window
    gh repo create <project-name> --private --source=. --remote=origin --push
  4. Add repository variable - set your Cloudflare account ID:

    Terminal window
    gh variable set CLOUDFLARE_ACCOUNT_ID --body "<your-cloudflare-account-id>"
  5. Add repository secret - set your Cloudflare API token:

    Terminal window
    gh secret set CLOUDFLARE_API_TOKEN
    Terminal window
    gh secret set CLOUDFLARE_API_TOKEN --app dependabot
  6. Done! 🎉

    Now let’s test the pipeline. Create a PR in your GitHub repository. An action will be triggered in the “Actions” section. If the basic checks pass, the workflow will perform a preview deployment to Cloudflare Workers and run a database migration on your preview database. After deployment, a “View deployment” button will appear in your PR with a link to the preview.

    When you merge the PR to main, a production deployment will occur and a database migration will be performed on your production database.