GitHub Actions — Deploy to Cloudflare Pages
Automated deployment pipeline to Cloudflare Pages with build preview for PRs and production on main.
name: Deploy to Cloudflare Pages
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install and build
run: |
npm ci
npm run build
- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: my-project
directory: out
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
# PR branches get preview URLs automaticallySponsored
GitHub
Use Cases
- Zero-config deployment for static Next.js exports
- Preview deployments for every pull request
- Continuous deployment to Cloudflare edge network
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
GitHub Actions — Node.js CI Pipeline
Complete CI workflow for Node.js: install, lint, test, build on every push and PR with caching.
Best for: Automated testing on every push and PR
Kubernetes Deployment Manifest
Production-ready Kubernetes deployment with resource limits, probes, rolling updates, and anti-affinity.
Best for: Deploying containerized applications to Kubernetes
GitHub Actions — Reusable Workflow Pattern
Create reusable workflows called from other workflows with inputs, secrets, and output passing.
Best for: DRY deployment workflows across environments
Vercel API — Trigger and List Deployments
Use the Vercel REST API to trigger deployments, list recent builds, and check deployment status.
Best for: Triggering deployments from CI or Slack bots