Cloudflare Pages Deployment Setup¶
This document describes how to deploy the MkDocs documentation site to Cloudflare Pages.
Architecture¶
The deployment uses GitHub Actions with the cloudflare/wrangler-action to build the MkDocs site and push it to Cloudflare Pages via direct upload. This avoids needing Cloudflare's Git integration and gives full control over the build process.
Workflow file: .github/workflows/deploy-cloudflare.yml
push to master → GitHub Actions → pip install + mkdocs build → wrangler pages deploy → Cloudflare Pages
Prerequisites¶
- A Cloudflare account (free tier is sufficient)
- The GitHub repo
marcoteodoro/progress-migration-docs(private, master branch)
Step 1: Create Cloudflare API Token¶
- Go to https://dash.cloudflare.com/profile/api-tokens
- Click Create Token
- Use the Custom token template
- Configure permissions:
- Account > Cloudflare Pages > Edit
- Account Resources: Include > select your account
- Click Continue to summary > Create Token
- Copy the token (you won't see it again)
Step 2: Get Your Cloudflare Account ID¶
- Go to https://dash.cloudflare.com
- Click on any domain (or the account overview)
- The Account ID is visible in the right sidebar, or in the URL:
https://dash.cloudflare.com/<ACCOUNT_ID>/... - Copy the Account ID (a 32-character hex string)
Step 3: Add GitHub Secrets¶
- Go to https://github.com/marcoteodoro/progress-migration-docs/settings/secrets/actions
- Click New repository secret and add:
- Name:
CLOUDFLARE_API_TOKEN/ Value: the token from Step 1 - Name:
CLOUDFLARE_ACCOUNT_ID/ Value: the account ID from Step 2
- Name:
Step 4: Create the Cloudflare Pages Project¶
The first deployment will auto-create the project. Alternatively, create it manually:
Option A: Auto-create (recommended)¶
Just push to master. The GitHub Action will run and create the progress-migration-docs project automatically on first deploy.
Option B: Manual creation via Cloudflare Dashboard¶
- Go to https://dash.cloudflare.com > Workers & Pages > Create
- Select the Pages tab
- Click Upload assets (NOT "Connect to Git" -- we use GitHub Actions for builds)
- Project name:
progress-migration-docs - Upload any placeholder file, then the GitHub Action will overwrite it on next push
Option C: Manual creation via CLI¶
Step 5: Verify Deployment¶
After pushing to master with the secrets configured:
- Check the GitHub Actions tab: https://github.com/marcoteodoro/progress-migration-docs/actions
- The "Deploy MkDocs to Cloudflare Pages" workflow should run successfully
- The site will be available at:
https://progress-migration-docs.pages.dev
Custom Domain (Optional)¶
To use a custom domain like docs.progresscu.ie:
- Go to Cloudflare Dashboard > Workers & Pages >
progress-migration-docs> Custom domains - Click Set up a custom domain
- Enter your domain (e.g.,
docs.progresscu.ie) - Cloudflare will configure the DNS automatically if the domain is on Cloudflare
Access Protection (Optional but Recommended)¶
Since this is internal documentation for a private project, you should restrict access.
Option A: Cloudflare Access (Zero Trust) -- Recommended¶
- Go to https://one.dash.cloudflare.com (Zero Trust dashboard)
- Navigate to Access > Applications > Add an application
- Select Self-hosted
- Configure:
- Application name: Progress Migration Docs
- Session duration: 24 hours
- Application domain:
progress-migration-docs.pages.dev(or your custom domain)
- Add a policy:
- Policy name: Allowed Users
- Action: Allow
- Include rule: Emails -- add authorized email addresses
- This will show a Cloudflare login page before allowing access to the docs
Option B: Simple Password via _headers File¶
Create a file at migration-review/_headers (this gets copied to _site/_headers during build):
Note: Cloudflare Pages does not support native basic auth. Use Cloudflare Access (Option A) for real authentication, or add X-Robots-Tag: noindex to at least prevent search engine indexing.
Deployment URL¶
| Environment | URL |
|---|---|
| Production | https://progress-migration-docs.pages.dev |
| Preview (non-master branches) | https://<branch>.progress-migration-docs.pages.dev |
| Custom domain (if configured) | https://docs.progresscu.ie (example) |
Troubleshooting¶
"Authentication error" in GitHub Actions¶
- Verify
CLOUDFLARE_API_TOKENandCLOUDFLARE_ACCOUNT_IDsecrets are set correctly - Verify the API token has Cloudflare Pages: Edit permission
- Tokens expire if you set an expiry -- check token validity
"Project not found" error¶
- The project auto-creates on first deploy. If it fails, create it manually (see Step 4 Option B or C)
- Project name must match exactly:
progress-migration-docs
Build fails with MkDocs errors¶
- Check
migration-review/requirements.txthas the right dependencies - The
--strictflag in mkdocs build will fail on broken links or warnings -- remove it temporarily to debug
Workflow Reference¶
The GitHub Actions workflow (.github/workflows/deploy-cloudflare.yml) does:
- Checks out the repo
- Sets up Python 3.12
- Caches pip dependencies
- Installs
mkdocs-materialfrommigration-review/requirements.txt - Runs
mkdocs build --strict(output to_site/) - Uses
cloudflare/wrangler-actionto deploy_site/to Cloudflare Pages