A Cloudflare Worker that listens for /preview comments on pull requests and triggers GitHub Actions workflows for preview deployments.
- Cloudflare account
- Node.js 18+
- Wrangler CLI: npm install -g wrangler
wrangler login
npm install
wrangler deploy- Go to GitHub Settings > Developer settings > GitHub Apps
- Click "New GitHub App"
- Fill in:
- GitHub App name: Preview Deploy Bot
- Webhook URL: https://your-worker.your-subdomain.workers.dev/webhook
- Webhook secret: Generate a secure random string
 
- GitHub App name: 
- Set permissions:
- Actions: Read & Write
- Contents: Read
- Issues: Write
- Metadata: Read
- Pull requests: Write
- Subscribe to: Issue comments
 
- Note down: App ID, private key, webhook secret
wrangler secret put GITHUB_APP_ID
wrangler secret put GITHUB_PRIVATE_KEY
wrangler secret put WEBHOOK_SECRET- Go to "Install App" tab in GitHub App settings
- Install on your account/organization
- Select repositories
- Comment /previewon any pull request
- Worker triggers GitHub Actions workflow
- Results are posted back as a comment
wrangler dev- Webhook not working: Check URL in GitHub App settings
- Auth errors: Verify secrets are set correctly
- Workflow not triggering: Ensure .github/workflows/preview-deploy.ymlexists
- View logs: wrangler tail