Webhook
Source:
src/GitHub/Webhook.ts
A GitHub repository webhook.
Webhook manages the lifecycle of a repository webhook that POSTs
events to a delivery URL. It is created on the first deploy and updated
in place on subsequent deploys, and is deleted when the resource is
destroyed.
Authentication is resolved via the GitHubCredentials service supplied
by GitHub.providers() (env, stored PAT, or gh CLI). The token needs
repo scope (admin access to the repository) to manage webhooks.
Most users don’t construct Webhook directly — prefer
{@link import(”./RepositoryEventSource.ts”).events | events(repository).subscribe(…)}
inside a Cloudflare Worker, which provisions the webhook, wires the
delivery URL to the Worker, and forwards verified events to your handler.
Creating a Webhook
Section titled “Creating a Webhook”Forward push events to a URL
yield* GitHub.Webhook("ci-webhook", { owner: "my-org", repository: "my-repo", url: "https://example.com/github", events: ["push", "pull_request"], secret: Redacted.make(process.env.WEBHOOK_SECRET!),});Point a webhook at a Worker
const worker = yield* Cloudflare.Worker("Api", { ... });
yield* GitHub.Webhook("repo-webhook", { owner: "my-org", repository: "my-repo", url: worker.url!, events: ["*"],});