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.
First deployment
Section titled “First deployment”-
Create a Cloudflare account - sign up at dash.cloudflare.com if you don’t have one yet.
-
Login to Cloudflare - in your project root directory, authenticate via the
wranglerCLI:Terminal window bunx wrangler login -
Reset your
wrangler.jsonconfig - initialise the config for your project:Terminal window bun setup:wrangler -
Deploy your app - deploy for preview and production environments:
Terminal window bun run deploy:previewTerminal window bun run deploy:production -
Migrate your database - run migrations for preview and production environments:
Terminal window bun run db:migrate --env preview --remoteTerminal window bun run db:migrate --env production --remote -
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
Section titled “Automatic deployment”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.
-
Complete the first deployment - follow the First deployment steps above to deploy your app and run database migrations.
-
Login to GitHub - authenticate via the
ghCLI:Terminal window gh auth login -
Create a GitHub repository - create a private repo and push all changes:
Terminal window gh repo create <project-name> --private --source=. --remote=origin --push -
Add repository variable - set your Cloudflare account ID:
Terminal window gh variable set CLOUDFLARE_ACCOUNT_ID --body "<your-cloudflare-account-id>" -
Add repository secret - set your Cloudflare API token:
Terminal window gh secret set CLOUDFLARE_API_TOKENTerminal window gh secret set CLOUDFLARE_API_TOKEN --app dependabot -
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.