Hooks
Last updated
Last updated
Hooks allow you to build or set up integrations that subscribe to certain events on DoltHub, such as pushing data. You give DoltHub the URL of an HTTP endpoint you've set up to accept POST requests, and then when certain events happen your endpoint will receive a payload.
Some common workflows involving hooks include:
Triggering continuous integration builds
Updating an external issue tracker
Creating automatic releases
DoltHub hooks currently only support push, pull request and branch events on a database, while GitHub supports a much longer list of events on both organizations and repositories.
If you have an event you'd like us to support, file an issue or reach out to us on Discord.
This blog covers an in depth example for how to set up a webhook for a push event on DoltHub. You can add and manage webhooks in the settings tab of any of your DoltHub databases.
This event occurs when a commit is pushed.
The payload delivered for a push event webhook contains information about the push that was made to the database. The payload is a JSON object that includes the following fields:
Key | Type | Description |
---|---|---|
| string | The name of the event triggered by the webhook. In this case, it will always be "push". |
| string | The name of the branch that was pushed. |
| string | The SHA of the most recent commit on |
| string | The SHA of the most recent commit on |
| string | The name of the database where the push occurred. |
| string | The owner (username or org name) of the database where the push occurred. |
An example of the payload:
The pull request event webhook is triggered whenever a pull request is created, merged, or closed. The payload includes these fields:
Key | Type | Description |
---|---|---|
| string | The name of the event triggered by the webhook. In this case, it will always be "pull_request". |
| string | The name of the database for the pull request base. |
| string | The owner (username or org name) of the pull request base. |
| string | The ID of the pull request that triggered the webhook. |
| string | The action that triggered the webhook (Opened, Closed, Merged.). |
| string | The current state of the pull request after the event. |
| string | The name of the database where the pull request is created from. |
| string | The owner of the database where the pull request is created from. |
| string | The branch that the pull request is created from. |
| string | The branch that the pull request wants to merge into. |
| string | The author of the pull request. |
| string | The user who triggered the event. |
An example of the payload object:
A branch Event Webhook is triggered when a branch is created or deleted. The payload includes these fields:
Key | Type | Description |
---|---|---|
| string | The name of the event. In this case, it will always be "branch". |
| string | The name of the database where the branch is located. |
| string | The owner (username or org name) of the database where the branch change occurred. |
| string | The full name of the branch (e.g., refs/heads/main). |
| string | The action that triggered the webhook (deleted or created the branch). |
An example of the payload: