From 3470b794d7b81abac784cbbb00e99b867d7261cb Mon Sep 17 00:00:00 2001 From: disqualifier Date: Mon, 22 Jun 2026 19:46:01 -0400 Subject: [PATCH] init: gitea-discord-proxy to proc whs Signed-off-by: disqualifier --- .gitignore | 6 ++++++ README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9360644 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.venv/ +venv/ +__pycache__/ +*.pyc +*.pyo +.env diff --git a/README.md b/README.md new file mode 100644 index 0000000..58a70da --- /dev/null +++ b/README.md @@ -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// + -> +http://127.0.0.1:8000/api/webhooks// +``` + +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//` (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.