Give every pull request its own isolated, ephemeral Cloudflare preview — a per-PR Worker wired to a per-PR D1, KV, and R2 — auto-deployed, dev data synced, migrations applied, and torn down when the PR closes.
📖 Documentation → cf-pr-preview.bbyb.dev
Full guides, syncing, and the complete input/output reference live on the docs site.
name: Preview
on:
pull_request:
types: [opened, synchronize, reopened, closed]
permissions:
contents: read
pull-requests: write
jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with: { bun-version: 1.3.14 }
- run: bun install
- uses: BitByBit-B3/cf-pr-preview-action@v1
with:
worker-prefix: myapp-preview
db-prefix: myapp-preview
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}Open a PR → get an isolated Worker + D1 + KV + R2 at a workers.dev URL, migrations applied, a
sticky comment with the link, and automatic teardown on close.
- Getting started — token scopes + the workflow
- Syncing dev data — clone dev D1 + R2 into previews
- Inputs & outputs — every option
bun install
bun run typecheck
bun test
bun run build # bundles src → dist/index.cjs (committed)dist/index.cjs is the committed entrypoint the action runs; CI fails if it drifts from src.
Docs live in docs/ (VitePress). See CONTRIBUTING.
MIT © BitByBit-B3
