Cloudflare Pages Deployment Guide
Prerequisites
- A Cloudflare account (the free tier is enough)
- GitHub repository:
xy111a/gtm-knowledge-base
Step 1: Get a Cloudflare API Token
- Sign in to the Cloudflare Dashboard
- Click the avatar in the top-right corner → My Profile → API Tokens
- Click Create Token
- Select the Cloudflare Pages template
- Configure permissions:
Account→Cloudflare Pages→EditZone→Zone→Read(if you need a custom domain)
- Click Continue to summary → Create Token
- Copy the generated token
Step 2: Get the Account ID
- The Account ID is shown in the right-hand sidebar of the Cloudflare Dashboard
- Alternatively, open the Overview page of any domain and the Account ID appears on the right
- Copy this ID
Step 3: Configure GitHub Secrets
- Open the GitHub repository (private; ask an admin for access):
xy111a/gtm-knowledge-base - Go to Settings → Secrets and variables → Actions
- Click New repository secret
- Add the following secrets:
| Name | Value |
|---|---|
CLOUDFLARE_API_TOKEN | The token obtained in Step 1 |
CLOUDFLARE_ACCOUNT_ID | The Account ID obtained in Step 2 |
Step 4: Create the Cloudflare Pages Project
Method A: Via the Cloudflare Dashboard (recommended)
- Sign in to the Cloudflare Dashboard
- Click Workers & Pages in the left sidebar
- Click Create → Pages → Connect to Git
- Select GitHub → select the
gtm-knowledge-baserepository - Configure the build settings:
- Production branch:
main - Build command:
pnpm install && pnpm run build - Build output directory:
docs/.vitepress/dist - Node.js version:
20
- Production branch:
- Click Save and Deploy
Method B: Via the Wrangler CLI
bash
# Install Wrangler
npm install -g wrangler
# Log in
wrangler login
# Create the Pages project
wrangler pages project create gtm-knowledge-base
# Manual deployment (optional, for testing)
cd gtm-site
pnpm install && pnpm run build
wrangler pages deploy docs/.vitepress/dist --project-name=gtm-knowledge-baseStep 5: Configure Automatic Deployment
Once the Cloudflare Pages project is linked to the GitHub repository, every push to the main branch automatically triggers a deployment.
Deployment Flow
Push code → GitHub Actions build → Cloudflare Pages deployment
↑
└── Feishu (Lark) sync (every 15 minutes) → automatic commit → triggers deploymentStep 6: Configure a Custom Domain (optional)
- Click Custom domains in the Cloudflare Pages project settings
- Enter your domain (e.g.
gtm.yourcompany.com) - Configure the DNS records as prompted
- The SSL certificate is provisioned automatically
Verify the Deployment
- Visit the default domain provided by Cloudflare Pages:
https://gtm-knowledge-base.pages.dev - Check that the site loads correctly
- Test the search function
- Test the interactive components (the P&L calculator, the Gantt chart, etc.)
Troubleshooting
The Build Fails
Check the GitHub Actions log:
- Open the repository Actions page (sign-in required for a private repo)
- Click the failed workflow
- Review the detailed error message
Feishu (Lark) Sync Fails
You need to configure the Feishu-related secrets:
| Name | Value |
|---|---|
FEISHU_APP_ID | Feishu Open Platform App ID |
FEISHU_APP_SECRET | Feishu Open Platform App Secret |
FEISHU_USER_ACCESS_TOKEN | User access token (optional) |
Search Does Not Work
VitePress generates the local-search index at build time, so make sure that:
- The documents have sufficient frontmatter (title, description)
- The build completed without errors
Monitoring
- Cloudflare Analytics: View traffic statistics in the Pages project
- GitHub Actions: View build status on the Actions page
- Cloudflare Status: https://www.cloudflarestatus.com/
Cost
| Service | Free Allowance | Estimated Cost for This Project |
|---|---|---|
| Cloudflare Pages | 500 builds/month, unlimited requests | $0 |
| GitHub Actions | 2000 minutes/month | $0 |
| Feishu API | Free | $0 |
| Total | $0/month |