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. If you don’t have a Cloudflare account, create one at https://dash.cloudflare.com/sign-up.

  2. Go to your project root directory

  3. Login to Cloudflare through wrangler CLI:

    Terminal window
    bunx wrangler login
  4. Create production and preview database:

    Terminal window
    bunx wrangler d1 create <project-name>-production
    bunx wrangler d1 create <project-name>-preview
  5. Update wrangler.json with the returned project name, database names, and database_ids

  6. Create Cloudflare Workers through initial deployment:

    Terminal window
    bun run deploy:production
    bun run deploy:preview
  7. Add the necessary secrets for your Cloudflare Workers:

    No secrets are needed for the open-source edition.

  1. Perform initial Cloudflare setup first to create D1 databases and Cloudflare Workers.

  2. Set the following environment variables in your project’s .env file:

    Terminal window
    CLOUDFLARE_ACCOUNT_ID=<your-cloudflare-account-id>
    CLOUDFLARE_API_TOKEN=<your-cloudflare-api-token>
  3. Perform Cloudflare D1 databases migrations:

    Terminal window
    bun run db:migrate:preview
    bun run db:migrate:production
  4. Perform Cloudflare Workers deployments:

    Terminal window
    bun run deploy:preview
    bun run deploy:production

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. Perform initial Cloudflare setup first to create D1 databases and Cloudflare Workers.

  2. Login through gh auth login

  3. Create a GitHub repo for the project and push all changes

    Terminal window
    gh repo create <project-name> --private --source=. --remote=origin --push
  4. Add the following repository variables:

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

    Terminal window
    gh secret set CLOUDFLARE_API_TOKEN
    gh secret set CLOUDFLARE_API_TOKEN --app dependabot

Now you can test everything. Create a PR in your project’s GitHub repository. You should see an action in the “Actions” section being triggered. 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 should appear in your PR with a link to the preview deployment.

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