We use cookies

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.

By clicking "Accept", you agree to our use of cookies.
Learn more.

CookbooksGitHub

GitHub Webhooks

GitHub can send webhooks for repository events — pushes, pull requests, issues, releases, and so on. This guide walks through connecting GitHub webhooks to Hatchet.

Setup

Create the webhook in Hatchet

In the Hatchet dashboard, go to Webhooks and create a new webhook with the following settings:

FieldValue
Namegithub (or whatever you’d like)
SourceGitHub
Event Key Expression'github:' + headers['x-github-event'] + ':' + input.action
SecretA secret string of your choosing (you’ll use the same one in GitHub)

A quick note on the event key expression: GitHub sends the event type (like pull_request or issues) in the x-github-event header, and the specific action (like opened or closed) in the payload’s action field. The expression above combines them to produce keys like github:pull_request:opened.

Not all GitHub events have an action field, though. Push events, for instance, don’t. If you want to handle events that might not have an action, you could use a simpler expression like 'github:' + headers['x-github-event'] and handle action-level routing in your task logic instead. Or you could create two separate webhooks — one for action-based events and one for action-less events.

Once you’ve created the webhook, copy the URL.

Configure the webhook in GitHub

Go to your repository (or organization) settings, find Webhooks, and add a new webhook. See GitHub’s webhook docs for the full walkthrough.

  1. Payload URL: Paste the Hatchet webhook URL.
  2. Content type: Select application/json.
  3. Secret: Enter the same secret you used when creating the webhook in Hatchet.
  4. Events: Choose “Let me select individual events” and pick the ones you care about, or select “Send me everything” if you prefer.
⚠️

Make sure you set the content type to application/json. GitHub defaults to application/x-www-form-urlencoded, which won’t work with Hatchet’s JSON payload parsing.

Write a task that listens for GitHub events

Here’s an example that triggers when a pull request is opened:

Test it

After saving the webhook in GitHub, GitHub will send a ping event to verify the connection. You can also use the “Redeliver” button in GitHub’s webhook settings to replay past events, or just open a PR to trigger a real event.