Automated testing and deployment of Cloudflare Workers using GitHub Actions or GitLab CI. Enables running tests on every commit, deploying to preview/staging/production environments automatically, managing secrets securely, and implementing deployment gates for safe releases.
Public variables (wrangler.jsonc) - Non-sensitive config
Secrets (wrangler secret) - API keys, tokens
CI variables (GitHub Secrets) - Deployment credentials
Setting secrets:
# Local development
wrangler secret put DATABASE_URL
# CI/CD (via GitHub Actions)
bunx wrangler secret put DATABASE_URL --env production <<< "${{ secrets.DATABASE_URL }}"
Preview Deployments
Automatically deploy each PR to a unique URL for testing:
Each PR gets URL like: my-worker-preview-42.workers.dev
Top 5 Use Cases
1. Deploy on Push to Main
name: Deploy Production
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun test
- run: bun run build
- name: Deploy to Production
uses: cloudflare/wrangler-action@v4
with:
api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: deploy --env production
Using GitHub environments and deployment protection
Implementing deployment gates and approvals
Load references/gitlab-ci.md when:
Setting up GitLab CI pipelines
Configuring GitLab environments
Using GitLab secret variables
Implementing review apps
Load references/deployment-strategies.md when:
Implementing blue-green deployments
Setting up canary releases
Configuring traffic splitting
Planning rollback procedures
Load references/secrets-management.md when:
Managing secrets across environments
Rotating API tokens
Using external secret providers (Vault, 1Password)
Implementing least-privilege access
Load templates/github-actions-full.yml for:
Complete production-ready GitHub Actions workflow
Multi-environment deployment example
All deployment gates configured
Load templates/gitlab-ci-full.yml for:
Complete GitLab CI pipeline
Multi-stage deployment
Review app configuration
Load templates/preview-deployment.yml for:
PR preview deployment setup
Automatic cleanup on PR close
Comment with preview URL
Load templates/rollback-workflow.yml for:
Manual rollback workflow
Deployment history tracking
Automated rollback on health check failure
Load scripts/verify-deployment.sh for:
Automated deployment verification
Health check implementation
Smoke tests after deployment
Secure Installation
When installing CI/CD dependencies, follow supply chain security best practices:
Block post-install scripts — npm config set ignore-scripts true (or Bun: disabled by default)
Frozen lockfiles in CI — Always use npm ci or bun install --frozen-lockfile
Security gate — Add socket ci to your CI pipeline to block PRs that violate your security policy
Load the dependency-upgrade skill for full security configuration including Socket CLI integration, cooldown setup, lockfile validation, and CI enforcement.
Related Cloudflare Plugins
For deployment testing, load:
cloudflare-workers-testing - Test Workers before deployment
cloudflare-manager - Manage deployments via Cloudflare API
This skill focuses on CI/CD automation for ALL Workers deployments regardless of bindings used.
Questions? Load references/secrets-management.md or use /workers-deploy command for guided deployment.