Cloudflare Pages Deployment via GitHub Tags
This setup ensures:- Every versioned tag (
v*), hotfix (hotfix-*), or rollback (rollback-*) deployment is deployed to production. - Rollbacks can be done easily using
git checkoutand re-tagging with arollback-*tag. - Static files in
./publicare deployed directly usingwrangler.
๐ง Prerequisites
1. Install and Configure wrangler.toml
Root of your repository
2. Create a Cloudflare API Token
Generate token here: ๐ Cloudflare API Token Settings Required permissions:- Account โ Cloudflare Pages โ Edit
- Zone โ Read
- (Optional) Restrict by account or project
๐ ๏ธ GitHub Actions Workflow
.github/workflows/cf.yaml
๐ Deployment Usage
๐ Normal Deployment
โ Automatically deploys tagv11to production (Cloudflare Pages โmainbranch)
๐งฏ Rollback to Previous Tag
Step-by-step:
โ
This will re-trigger the deployment to production using the v10 commit
๐งช Example Tags You Can Use
| Tag Name | Purpose |
|---|---|
v1, v2 | Normal release |
hotfix-v2 | Emergency patch |
rollback-v1 | Rollback to old tag |
๐ Notes
- Cloudflare uses the
--branch mainflag to treat this as a production deployment. - Tags point to commits, so you can roll back by creating a new tag from an older commit.
- Wrangler uses
./publicas the deployment directory (you can customize viawrangler.toml). - You must use Node.js v20+ as required by Wrangler 4.x.
โ Final Checklist
-
wrangler.tomlwithpages_build_output_dir - GitHub secret:
CLOUDFLARE_API_TOKEN - GitHub Action workflow deployed on tag
- Use
rollback-*tags to trigger safe rollback
