init: gitea-discord-proxy to proc whs
Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
commit
3470b794d7
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.venv/
|
||||||
|
venv/
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
.env
|
||||||
51
README.md
Normal file
51
README.md
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
# gitea-discord-proxy
|
||||||
|
|
||||||
|
A tiny passthrough that makes Gitea's Discord webhook notifications render like
|
||||||
|
GitHub's. Gitea sends a native Discord embed; this proxy rewrites only the embed
|
||||||
|
description into GitHub style (backticked commit hash, message collapsed to its
|
||||||
|
first line, author kept) and forwards the otherwise-untouched payload to the real
|
||||||
|
Discord webhook.
|
||||||
|
|
||||||
|
## How it works
|
||||||
|
|
||||||
|
It mirrors Discord's webhook path, so you point a Gitea webhook at this proxy by
|
||||||
|
swapping the hostname:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://discord.com/api/webhooks/<id>/<token>
|
||||||
|
->
|
||||||
|
http://127.0.0.1:8000/api/webhooks/<id>/<token>
|
||||||
|
```
|
||||||
|
|
||||||
|
The real Discord webhook id/token live in the path, so one proxy serves every
|
||||||
|
repo — no per-repo config. Gitea and the proxy run on the same host, so traffic
|
||||||
|
stays on localhost; nothing is exposed publicly.
|
||||||
|
|
||||||
|
## Run
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
uvicorn app:app --host 127.0.0.1 --port 8000
|
||||||
|
```
|
||||||
|
|
||||||
|
Health check at `GET /healthz`.
|
||||||
|
|
||||||
|
## Gitea webhook setup
|
||||||
|
|
||||||
|
Per repo (or as a default/system webhook):
|
||||||
|
|
||||||
|
- **Type:** Discord
|
||||||
|
- **Target URL:** `http://127.0.0.1:8000/api/webhooks/<id>/<token>` (the real
|
||||||
|
webhook's id/token, host swapped to the proxy)
|
||||||
|
- **Content type:** application/json
|
||||||
|
- **Trigger:** Push Events (or whatever you want)
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- The reformat regex is matched to Gitea's current Discord embed description
|
||||||
|
format (`[hash](url) message - author`, commits joined by newlines). If a
|
||||||
|
future Gitea version changes that layout, the regex in `app.py` needs a small
|
||||||
|
tweak. This is the tradeoff for reformatting Gitea's pre-built embed rather
|
||||||
|
than parsing raw push payloads.
|
||||||
|
- Title, branches, multiple commits, tags, and colors pass through as Gitea
|
||||||
|
produced them.
|
||||||
Loading…
Reference in New Issue
Block a user