Gitea and Forgejo
A Gitea or Forgejo repository's (or organisation's) pushes, pull requests, issues, comments and releases arrive as short messages, each linking to the thing itself. Both use the same steps and the same template: gitea, which also answers to the name forgejo.
Setting it up#
In the app these steps are under Connect a system → Gitea / Forgejo, or a topic's Send to this topic tab, with the address, topic and a token filled in; New token makes the token.
A repository (or organisation) webhook. Events the template does not cover, or you switch off below, answer normally and store nothing.
Settings → Webhooks → Add webhook → Gitea (on Forgejo: Forgejo):
- Target URL:
https://notify.example.com/gitea?template=gitea - HTTP Method: POST
- POST Content Type:
application/json - Secret: leave empty
- Trigger On: Custom Events…
- Events: Push, Pull Request, Issues, Issue Comment, Pull Request Comment, Release
- Authorization Header:
Bearer tk_replace_with_your_token
- Target URL:
Add Webhook. On the webhook’s page, Test Push Event sends the last push. (Forgejo’s labels are the same in sentence case.)
The steps here show example values (https://notify.example.com, the topic gitea, tk_replace_with_your_token): copy them from the app, where yours are filled in.
- On Forgejo, pick the webhook type Forgejo; on Gitea, Gitea. Skirl reads the kind of event from either one's header.
- Gitea delivers webhooks only to addresses on the internet unless it is told otherwise. If Skirl's address is on your own network, allow it in Gitea's
app.ini, for exampleALLOWED_HOST_LIST = private(Gitea 28 has it under[security]; older versions under[webhook]), and restart Gitea. - The events you tick in Skirl are in the Target URL (
&events=…): after changing them, copy the address into Gitea again. - Skirl's tests run these steps against Gitea 28.4.0. Forgejo is not run in the tests.
Events#
| Event | On at first | What it means |
|---|---|---|
| Pushes | Yes | Commits pushed: who, how many, the branch, and the first five commits. A push with no commits (a new branch, a tag) is not sent. |
| Pull request opened or reopened | Yes | The branches and the author. |
| Pull request merged | Yes | A pull request merged. |
| Pull request closed without merge | Yes | A pull request closed and not merged. |
| Issue opened or reopened | Yes | Who opened it, and its text. |
| Issue closed | Yes | Who closed it. |
| Comments | Yes | A new comment on an issue or a pull request. |
| Release published | Yes | The release and its notes. |
Every message is at priority 3. Anything else Gitea sends (a branch or tag created or deleted, a pull request updated with new commits, a fork) is answered normally and dropped.
What a message looks like#
A push, as Gitea 28.4.0 sent it:
ops pushed 3 commits to main · ops/infra
8143eea Fix the backup schedule
457e623 Add nas02 to the inventory
dd58ca9 Bump TraefikPriority 3 · Tags: arrow_up, infra
A pull request merged:
PR #1 merged: Add nas02 · ops/infra
nas02 → main, by opsPriority 3 · Tags: twisted_rightwards_arrows, infra
Tapping a message opens the comparison of a push, the pull request, the issue, the comment or the release. The first tag shows as an emoji (⬆️, 🔀); the second is the repository's name.
When nothing arrives#
- Press Test Push Event on the webhook's page in Gitea. It sends the last push, which arrives as "ops pushed 1 commit to main · ops/infra" (with your names). Gitea's list of recent deliveries on the same page shows Skirl's answer.
- Gitea refuses to deliver to Skirl's address. It is on your own network: see
ALLOWED_HOST_LISTabove. - The answer is 401 or 403. The Authorization Header must be
Bearerfollowed by the token. 401: the token is wrong, rotated or revoked; 403: it is a token for another topic. - The answer is 400, "message body must be JSON". POST Content Type is not
application/json. - The answer is 200 with
"dropped":true. Skirl took it and dropped it on purpose: the event is not ticked in Skirl, or it is one Skirl does not send. - There is no answer at all: A sender gets no message through.