Webhooks
Forgejo supports webhooks for repository events. This can be configured in the settings
page /:username/:reponame/settings/hooks
by a repository admin. Webhooks can also be configured on a per-organization and whole system basis (default webhooks on repository creation or instance-wide webhooks).
The currently supported webhook types are:
Raw event as JSON or FORM payload:
- Forgejo (GET or POST)
- Gitea (GET or POST)
- Gogs (POST)
Dedicated integration:
- Packagist: ask packagist to refresh the given package
- SourceHut Builds: submit build manifests (only on push)
Generic notification messages in chosen channel/chat:
- Matrix
- Slack
- Discord
- Dingtalk
- Telegram
- Microsoft Teams
- Feishu / Lark Suite
- WeCom (Wechat Work)
Event information
The following is an example of event information that will be sent by Forgejo to a Payload URL:
Example
This is an example of how to use webhooks to run a PHP script upon push requests to the repository. In your repository Settings, under Webhooks, Setup a Forgejo webhook as follows:
- Target URL: http://example.com/webhook.php
- HTTP Method: POST
- POST Content Type: application/json
- Secret: 123
- Trigger On: Push Events
- Active: Checked
Now on your server create the PHP file webhook.php
There is a Test Delivery button in the webhook settings that allows to test the configuration as well as a list of the most Recent Deliveries.
Authorization header
Forgejo webhooks can be configured to send an authorization header to the target.
The authentication string is stored encrypted in the database.