Event subscriptions(イベントサブスクリプション)を使うと、Cloudflare アカウント全体でイベントが発生したときにメッセージを受け取れます。Cloudflare の製品(例: KV、Workers AI、Workers)は、構造化されたイベントを queue へ公開できます。その後、Workers または HTTP pull consumers で消費し、カスタムワークフロー、連携、ロジックを構築できます。
Event Subscriptions の詳細は、管理ガイド を参照してください。
ビルドイベントを消費し、Slack、Discord、または任意の webhook エンドポイントへ通知を送る Worker をデプロイできます。
テンプレートは次の通知を送ります。
- プレビューまたは本番デプロイの URL 付きの成功したビルド
- エラーメッセージ付きの失敗したビルド
- キャンセルされたビルド
webhook プロバイダー向けに、Worker のメッセージ形式をカスタマイズできます。セットアップ手順は テンプレートの README ↗ を参照してください。
ビルドが開始したときに発生します。
例:
{
"type": "cf.workersBuilds.worker.build.started",
"source": {
"type": "workersBuilds.worker",
"workerName": "my-worker"
},
"payload": {
"buildUuid": "build-12345678-90ab-cdef-1234-567890abcdef",
"status": "running",
"buildOutcome": null,
"createdAt": "2025-05-01T02:48:57.132Z",
"initializingAt": "2025-05-01T02:48:58.132Z",
"runningAt": "2025-05-01T02:48:59.132Z",
"stoppedAt": null,
"buildTriggerMetadata": {
"buildTriggerSource": "push_event",
"branch": "main",
"commitHash": "abc123def456",
"commitMessage": "Fix bug in authentication",
"author": "[email protected]",
"buildCommand": "npm run build",
"deployCommand": "wrangler deploy",
"rootDirectory": "/",
"repoName": "my-worker-repo",
"providerAccountName": "github-user",
"providerType": "github"
}
},
"metadata": {
"accountId": "f9f79265f388666de8122cfb508d7776",
"eventSubscriptionId": "1830c4bb612e43c3af7f4cada31fbf3f",
"eventSchemaVersion": 1,
"eventTimestamp": "2025-05-01T02:48:57.132Z"
}
}ビルドが失敗したときに発生します。
例:
{
"type": "cf.workersBuilds.worker.build.failed",
"source": {
"type": "workersBuilds.worker",
"workerName": "my-worker"
},
"payload": {
"buildUuid": "build-12345678-90ab-cdef-1234-567890abcdef",
"status": "failed",
"buildOutcome": "failure",
"createdAt": "2025-05-01T02:48:57.132Z",
"initializingAt": "2025-05-01T02:48:58.132Z",
"runningAt": "2025-05-01T02:48:59.132Z",
"stoppedAt": "2025-05-01T02:50:00.132Z",
"buildTriggerMetadata": {
"buildTriggerSource": "push_event",
"branch": "main",
"commitHash": "abc123def456",
"commitMessage": "Fix bug in authentication",
"author": "[email protected]",
"buildCommand": "npm run build",
"deployCommand": "wrangler deploy",
"rootDirectory": "/",
"repoName": "my-worker-repo",
"providerAccountName": "github-user",
"providerType": "github"
}
},
"metadata": {
"accountId": "f9f79265f388666de8122cfb508d7776",
"eventSubscriptionId": "1830c4bb612e43c3af7f4cada31fbf3f",
"eventSchemaVersion": 1,
"eventTimestamp": "2025-05-01T02:48:57.132Z"
}
}ビルドがキャンセルされたときに発生します。
例:
{
"type": "cf.workersBuilds.worker.build.canceled",
"source": {
"type": "workersBuilds.worker",
"workerName": "my-worker"
},
"payload": {
"buildUuid": "build-12345678-90ab-cdef-1234-567890abcdef",
"status": "canceled",
"buildOutcome": "canceled",
"createdAt": "2025-05-01T02:48:57.132Z",
"initializingAt": "2025-05-01T02:48:58.132Z",
"runningAt": "2025-05-01T02:48:59.132Z",
"stoppedAt": "2025-05-01T02:49:30.132Z",
"buildTriggerMetadata": {
"buildTriggerSource": "push_event",
"branch": "main",
"commitHash": "abc123def456",
"commitMessage": "Fix bug in authentication",
"author": "[email protected]",
"buildCommand": "npm run build",
"deployCommand": "wrangler deploy",
"rootDirectory": "/",
"repoName": "my-worker-repo",
"providerAccountName": "github-user",
"providerType": "github"
}
},
"metadata": {
"accountId": "f9f79265f388666de8122cfb508d7776",
"eventSubscriptionId": "1830c4bb612e43c3af7f4cada31fbf3f",
"eventSchemaVersion": 1,
"eventTimestamp": "2025-05-01T02:48:57.132Z"
}
}ビルドが成功したときに発生します。
例:
{
"type": "cf.workersBuilds.worker.build.succeeded",
"source": {
"type": "workersBuilds.worker",
"workerName": "my-worker"
},
"payload": {
"buildUuid": "build-12345678-90ab-cdef-1234-567890abcdef",
"status": "success",
"buildOutcome": "success",
"createdAt": "2025-05-01T02:48:57.132Z",
"initializingAt": "2025-05-01T02:48:58.132Z",
"runningAt": "2025-05-01T02:48:59.132Z",
"stoppedAt": "2025-05-01T02:50:15.132Z",
"buildTriggerMetadata": {
"buildTriggerSource": "push_event",
"branch": "main",
"commitHash": "abc123def456",
"commitMessage": "Fix bug in authentication",
"author": "[email protected]",
"buildCommand": "npm run build",
"deployCommand": "wrangler deploy",
"rootDirectory": "/",
"repoName": "my-worker-repo",
"providerAccountName": "github-user",
"providerType": "github"
}
},
"metadata": {
"accountId": "f9f79265f388666de8122cfb508d7776",
"eventSubscriptionId": "1830c4bb612e43c3af7f4cada31fbf3f",
"eventSchemaVersion": 1,
"eventTimestamp": "2025-05-01T02:48:57.132Z"
}
}