chore: update gitea-chat-bridge/main.py via opax-mcp
Some checks are pending
Check Python Version Consistency / Check Python Version (push) Waiting to run
Some checks are pending
Check Python Version Consistency / Check Python Version (push) Waiting to run
This commit is contained in:
parent
3f4765e352
commit
f467e5bea6
24
gitea-chat-bridge/main.py
Normal file
24
gitea-chat-bridge/main.py
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import functions_framework
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
|
||||||
|
CHAT_WEBHOOK = os.environ.get("CHAT_WEBHOOK_URL")
|
||||||
|
|
||||||
|
@functions_framework.http
|
||||||
|
def handler(request):
|
||||||
|
try:
|
||||||
|
payload = request.get_json(silent=True) or {}
|
||||||
|
repo = payload.get("repository", {}).get("full_name", "unknown")
|
||||||
|
pusher = payload.get("pusher", {}).get("login", "unknown")
|
||||||
|
ref = payload.get("ref", "").replace("refs/heads/", "")
|
||||||
|
commits = payload.get("commits", [])
|
||||||
|
lines = [f"\U0001f500 *Push til {repo}* \u2014 branch {ref} av {pusher}"]
|
||||||
|
for c in commits[:5]:
|
||||||
|
sha = c.get("id","")[:7]
|
||||||
|
msg = c.get("message","").split("\n")[0][:80]
|
||||||
|
url = c.get("url","")
|
||||||
|
lines.append(f" \u2022 {sha}: {msg}\n {url}")
|
||||||
|
requests.post(CHAT_WEBHOOK, json={"text": "\n".join(lines)}, timeout=5)
|
||||||
|
return ("OK", 200)
|
||||||
|
except Exception as e:
|
||||||
|
return (str(e), 500)
|
||||||
Loading…
Reference in New Issue
Block a user