// "Use this skill whenever the user wants to set up, refactor, or maintain a GitHub Actions CI/CD pipeline for deploying Cloudflare Workers/Pages apps (e.g. Hono + TypeScript) with D1/R2, including tests, build, migrations, and multi-environment deploys."
| name | cloudflare-ci-cd-github-actions |
| description | Use this skill whenever the user wants to set up, refactor, or maintain a GitHub Actions CI/CD pipeline for deploying Cloudflare Workers/Pages apps (e.g. Hono + TypeScript) with D1/R2, including tests, build, migrations, and multi-environment deploys. |
You are a specialized assistant for automating deployment of Cloudflare Workers/Pages apps using GitHub Actions.
Use this skill to:
Do not use this skill for:
If CLAUDE.md describes CI/CD standards (job naming, env naming, required checks), follow them.
Trigger this skill when the user says things like:
Avoid when:
This skill expects the following GitHub repo secrets (names can be customized):
CLOUDFLARE_API_TOKEN – API Token with appropriate permissions for Workers & D1/R2
CLOUDFLARE_ACCOUNT_ID – Cloudflare account ID
Optionally environment-specific:
CLOUDFLARE_API_TOKEN_STAGINGCLOUDFLARE_API_TOKEN_PRODUCTIONThese secrets are configured in GitHub → Settings → Secrets and variables → Actions.
Within workflows, they are accessed via ${{ secrets.CLOUDFLARE_API_TOKEN }} etc.
The skill generally recommends at least two workflows:
ci.yml – Tests & checks (PRs, pushes).deploy.yml – Build + deploy (staging/prod) on specific branches or tags.# .github/workflows/ci.yml
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Lint
run: npm run lint --if-present
- name: Test
run: npm test --if-present
This skill can adapt npm → pnpm/yarn based on lockfiles.
# .github/workflows/deploy.yml
name: Deploy to Cloudflare
on:
push:
branches:
- main # production deploy
- develop # staging deploy
jobs:
deploy:
runs-on: ubuntu-latest
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Install Wrangler
run: npm install -g wrangler
- name: Determine environment
id: env
run: |
if [[ "${GITHUB_REF##*/}" == "main" ]]; then
echo "env_name=production" >> "$GITHUB_OUTPUT"
else
echo "env_name=staging" >> "$GITHUB_OUTPUT"
fi
- name: Deploy with Wrangler
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
if [ "${{ steps.env.outputs.env_name }}" = "production" ]; then
wrangler deploy --env production
else
wrangler deploy --env staging
fi
This is a baseline; this skill will customize it with migrations, R2, etc., per project.
When cloudflare-d1-migrations-and-production-seeding is present, this skill will:
wrangler.toml and DB names.Example augmented snippet:
- name: Run D1 migrations
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
if [ "${{ steps.env.outputs.env_name }}" = "production" ]; then
wrangler d1 migrations apply my_db_prod --env production
else
wrangler d1 migrations apply my_db_staging --env staging
fi
Ordering options:
wrangler deploy with integrated migrations if using more advanced patterns.This skill should:
For feature branches & PRs, this skill can set up preview Workers:
wrangler deploy --name my-app-pr-${{ github.event.number }}.Example preview workflow:
# .github/workflows/preview.yml
name: Preview Deploy
on:
pull_request:
jobs:
preview:
runs-on: ubuntu-latest
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm install
- run: npm install -g wrangler
- name: Deploy Preview
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
run: |
wrangler deploy --name "my-hono-api-pr-${{ github.event.number }}" --var "NODE_ENV:preview"
This skill will:
github-script or similar).This skill configures caching to make CI faster:
Node modules cache (via actions/setup-node with cache).
If using pnpm:
- uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
- uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
For pnpm install instead of npm install.
This skill will auto-detect package manager based on lockfile names in the repo, when context permits.
This skill helps design environment mapping:
develop branch → staging environment in wrangler.tomlmain branch → production environmentOptionally:
feature/* branches → preview Worker instancesPermissions & tokens:
CLOUDFLARE_API_TOKEN with scoped permissions for all envs, orCLOUDFLARE_API_TOKEN_STAGINGCLOUDFLARE_API_TOKEN_PRODUCTIONThen choose inside the workflow:
- name: Select API token
id: token
run: |
if [[ "${GITHUB_REF##*/}" == "main" ]]; then
echo "value=${{ secrets.CLOUDFLARE_API_TOKEN_PRODUCTION }}" >> "$GITHUB_OUTPUT"
else
echo "value=${{ secrets.CLOUDFLARE_API_TOKEN_STAGING }}" >> "$GITHUB_OUTPUT"
fi
Then export as CLOUDFLARE_API_TOKEN for Wrangler.
This skill will guide around:
wrangler deploy --tag <release-tag> when tags are used).It can also suggest tagging releases in Git (v1.2.3) and tying deploys to tags.
This skill should ensure:
It can suggest:
deploy workflow to protected branches (main, release/*).main.cloudflare-worker-deployment:
wrangler.toml and env naming.cloudflare-d1-migrations-and-production-seeding:
cloudflare-r2-bucket-management-and-access:
wrangler.toml; CI/CD ensures deployments target correct env.hono-app-scaffold, hono-d1-integration, hono-r2-integration:
For such tasks, rely on this skill to build a clean, robust GitHub Actions pipeline that automates testing, building, migrating, and deploying your Cloudflare Workers/Pages-based apps.