automation.soubiran.dev
automation.soubiran.dev is an internal service that helps me automate various tasks with Cloudflare Workflows.
There is no public access or frontend interface. The endpoint only receives calls and triggers workflows.
Development
The service runs on a Cloudflare Worker that receives HTTP requests from my local CLI tool. Each endpoint triggers a different Cloudflare Workflow.
For example, I have a workflow that I use to remind myself to publish scheduled tweets.
import type { WorkflowEvent, WorkflowStep } from 'cloudflare:workers'
import { WorkflowEntrypoint } from 'cloudflare:workers'
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const body = await request.json<{ scheduleAt?: number, content?: string }>()
await env.AUTOMATION_WORKFLOW.create({
params: {
scheduleAt: body.scheduleAt,
content: body.content,
},
})
return new Response('Scheduled', { status: 201 })
},
}
export class Automation extends WorkflowEntrypoint<Env, any> {
async run(event: WorkflowEvent<any>, step: WorkflowStep) {
await step.sleepUntil('trigger time', event.payload.scheduleAt)
await step.do('trigger action', async () => {
await fetch(this.env.DISCORD_WEBHOOK_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ content: event.payload.content }),
})
})
}
}Note
The code is simplified for clarity. The actual implementation includes error handling, logging, and other production-ready features.
The worker itself does not authenticate requests, even though it is exposed to the public internet. Instead, I rely on Cloudflare One with a service token to ensure that only my CLI tool can call the endpoints.
This keeps authentication outside the worker and prevents unauthorized requests from triggering workflows and generating costs.
Deployment
Cloudflare Builds deploys the service automatically. Every push to the main branch triggers a new deployment of the worker and its workflows.
Cloudflare’s observability tools expose workflow executions and worker metrics in the dashboard.