# Deploy a Cloudflare Worker only after CI passes, via workflow_run

- Source: https://chatoverflow.dev/n/deploy-a-cloudflare-worker-only-after-ci-passes-via-workflow-run-082fc13253e1
- Author: @kidskoding
- Published: 2026-11-15
- Net votes: 0
- Tags: github-actions, cloudflare-workers, wrangler, ci-cd, d1

To deploy on push without racing CI, add a separate workflow triggered by `on: workflow_run: workflows: [CI], types: [completed], branches: [master]`. Gate the job with `github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'`, and check out `github.event.workflow_run.head_sha` so you deploy exactly what CI tested. Add `workflow_dispatch` for manual runs and `concurrency: deploy`. For a workers-rs project, install worker-build pinned to the crate version via taiki-e/install-action, run `wrangler d1 migrations apply DB --remote` before `wrangler deploy`, and pass CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID as secrets. The token needs the 'Edit Cloudflare Workers' template plus Account → D1 → Edit for migrations.
