An internal service to redeploy other internal services.
A Cloudflare Worker + Workflow service that optionally waits for the latest deployment of a Worker and then POSTs a Cloudflare deploy hook URL.
zodevlog/workers in the Worker + evlog wide events in the Workflowpnpm install
Copy .env.example to .env.
If you use cloudflare.to_wait.worker, provide a user API token with access to the Workers resources needed to inspect deployments. If you only trigger deploy_hook_url immediately, the token is not used by the redeploy flow itself.
CLOUDFLARE_API_TOKEN=...
Run locally:
pnpm run dev
Every request emits a Worker log event, and every workflow execution emits its own wide event. To make events easy to identify and correlate:
x-service when calling the WorkerTrigger a Cloudflare deploy hook URL after another worker deployment is successful:
POST /url
Content-Type: application/json
{
"deploy_hook_url": "https://api.cloudflare.com/client/v4/workers/builds/deploy_hooks/abc123",
"cloudflare": {
"to_wait": {
"worker": "talks"
}
}
}
Trigger a Cloudflare deploy hook URL immediately without waiting:
POST /url
Content-Type: application/json
{
"deploy_hook_url": "https://api.cloudflare.com/client/v4/workers/builds/deploy_hooks/abc123"
}
If input is invalid (malformed JSON or schema mismatch), the API returns 400 Bad Request.
If workflow execution fails later, the workflow run emits its own error event with the workflow instance id and Cloudflare deployment context when available.
pnpm installpnpm run devpnpm run lintpnpm run deploypnpm run cf-typegenWhen running locally, you can use HTTPie to test the API. This is easier than using a GUI like Postman.
Trigger a Cloudflare deploy hook URL after another worker deployment is successful:
http --verbose --json POST localhost:8787/url \
deploy_hook_url=https://api.cloudflare.com/client/v4/workers/builds/deploy_hooks/abc123 \
cloudflare:='{"to_wait":{"worker":"talks"}}' \
x-service:soubiran.dev
Trigger a Cloudflare deploy hook URL immediately:
http --verbose --json POST localhost:8787/url \
deploy_hook_url=https://api.cloudflare.com/client/v4/workers/builds/deploy_hooks/abc123 \
x-service:soubiran.dev
[!NOTE]
Remember to use real target names that exist in your Cloudflare account.
Quick negative tests:
# Wrong route (expect 404)
http --verbose --json POST localhost:8787/soubiran-dev cloudflare:='{"to_wait":{"worker":"talks"}}'
# Invalid body shape (expect 400: deploy_hook_url is required)
http --verbose --json POST localhost:8787/url cloudflare:='{"to_wait":{"worker":"talks"}}'
# Invalid body shape (expect 400: invalid deploy hook URL)
http --verbose --json POST localhost:8787/url deploy_hook_url=not-a-url
# Malformed JSON (expect 400)
echo '{bad json' | http --verbose POST localhost:8787/url Content-Type:application/json
MIT License