whatisgithub

What is cf-pr-preview-action?

bitbybit-b3/cf-pr-preview-action — explained in plain English

Analysis updated 2026-05-18

0TypeScriptAudience · ops devopsComplexity · 3/5LicenseSetup · moderate

In one sentence

A GitHub Action that spins up an isolated Cloudflare Worker, D1 database, KV store, and R2 bucket for each pull request, then tears them down when the PR closes.

Mindmap

mindmap
  root((cf-pr-preview-action))
    What it does
      Per PR Worker
      Per PR D1 KV R2
      Auto teardown
    Tech stack
      TypeScript
      Bun
      Cloudflare Workers
    Use cases
      PR preview links
      Migrations applied
      Dev data sync
    Audience
      DevOps
      CI CD teams

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Give every pull request its own live Cloudflare preview URL for reviewers to test.

USE CASE 2

Automatically apply database migrations to a fresh D1 instance per pull request.

USE CASE 3

Sync existing development data into each preview instead of starting from empty.

What is it built with?

TypeScriptBunCloudflare WorkersCloudflare D1Cloudflare KVCloudflare R2GitHub Actions

How does it compare?

bitbybit-b3/cf-pr-preview-action0xkinno/astraea0xkinno/halcyon
Stars000
LanguageTypeScriptTypeScriptTypeScript
Setup difficultymoderatehardhard
Complexity3/54/54/5
Audienceops devopsdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires a Cloudflare API token and account ID stored as GitHub Actions secrets.

MIT license: free to use, modify, and distribute, as long as the copyright notice is kept.

So what is it?

cf-pr-preview-action is a GitHub Action that gives every pull request its own temporary, isolated preview environment on Cloudflare. When a pull request is opened, the action creates a dedicated Cloudflare Worker along with its own D1 database, KV store, and R2 bucket just for that PR, deploys the code to it, runs any database migrations, and posts a comment on the pull request with a link to the live preview. When the pull request is closed, all of that infrastructure is torn down automatically, so nothing is left running. Setting it up means adding a step to a GitHub Actions workflow file that triggers on pull request events such as opened, updated, reopened, and closed. The example configuration installs dependencies with a tool called Bun, then calls this action with a couple of naming inputs for the preview Worker and database, along with a Cloudflare API token and account ID passed in as secrets. From there, opening a pull request produces a working preview at a workers.dev address, with a comment on the PR that updates as the preview changes and disappears when the PR closes. The action also supports syncing data from an existing development environment into each preview, so a preview does not have to start from an empty database. Full documentation, including token permission scopes, the complete list of configuration inputs and outputs, and the data syncing guide, lives on a separate documentation site linked from the README rather than in the README itself. For anyone contributing to the action itself, the project is written in TypeScript, uses Bun for installing packages, type checking, and testing, and builds down to a single committed file that GitHub Actions actually runs, with continuous integration checking that this built file stays in sync with the source. The project is released under the MIT license, a permissive license that allows free use, modification, and distribution as long as the copyright notice is kept.

Copy-paste prompts

Prompt 1
Write a GitHub Actions workflow that uses cf-pr-preview-action to deploy a preview on every pull request.
Prompt 2
Show me how to pass CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as secrets to cf-pr-preview-action.
Prompt 3
Explain how to configure worker-prefix and db-prefix inputs for cf-pr-preview-action.
Prompt 4
Help me set up dev data syncing so each PR preview clones the development D1 and R2 data.

Frequently asked questions

What is cf-pr-preview-action?

A GitHub Action that spins up an isolated Cloudflare Worker, D1 database, KV store, and R2 bucket for each pull request, then tears them down when the PR closes.

What language is cf-pr-preview-action written in?

Mainly TypeScript. The stack also includes TypeScript, Bun, Cloudflare Workers.

What license does cf-pr-preview-action use?

MIT license: free to use, modify, and distribute, as long as the copyright notice is kept.

How hard is cf-pr-preview-action to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is cf-pr-preview-action for?

Mainly ops devops.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.