[Automation] Gitea webhooks → gateway — auto-react to repo events #77

Closed
opened 2026-03-20 14:54:45 -04:00 by perplexity · 1 comment
Owner

Overview

Add a /webhook/gitea REST endpoint to the gateway. When Gitea fires webhooks (push, PR, issue, comment), the gateway translates them into Matrix protocol messages and broadcasts to all connected clients.

Timmy reacts automatically — barks commit messages, inspects PRs, places issue artifacts.

Changes

server/gateway.py

New REST endpoint:

  • POST /api/webhook/gitea — receives raw Gitea webhook payload
  • Validates X-Gitea-Event header for event type
  • Translates to Matrix messages:
    • pushbark (commit message) + agent_state:working
    • pull_request.openedbark + agent_behavior:inspect
    • pull_request.closed+mergedbark (celebration) + scene_add (merge artifact)
    • issues.openedbark + agent_behavior:place (issue artifact)
    • issue_comment.createdbark (comment excerpt)
  • Broadcasts translated messages to all WS clients
  • Optional: X-Gitea-Secret validation

server/webhooks.py (NEW)

Webhook translator module:

  • translate_push(payload) -> list[dict] — Matrix messages for push
  • translate_pr(payload) -> list[dict] — Matrix messages for PR events
  • translate_issue(payload) -> list[dict] — Matrix messages for issue events
  • translate_comment(payload) -> list[dict] — Matrix messages for comments
  • Filters bot-only activity (hermes, kimi, manus) unless PR merge
  • Uses same bot filter list as dashboard gitea_adapter.py

PROTOCOL.md

Document webhook_event message type.

Acceptance Criteria

  • Gateway accepts POST /api/webhook/gitea with Gitea payloads
  • Push events → bark with commit message + author
  • PR merge → bark + scene artifact
  • Issue opened → bark + artifact
  • Bot-only pushes filtered (unless PR merge)
  • Tests with mock webhook payloads
  • Gitea webhook can be configured to point at gateway URL

Depends On

Nothing — standalone addition to gateway REST API.

## Overview Add a `/webhook/gitea` REST endpoint to the gateway. When Gitea fires webhooks (push, PR, issue, comment), the gateway translates them into Matrix protocol messages and broadcasts to all connected clients. Timmy reacts automatically — barks commit messages, inspects PRs, places issue artifacts. ## Changes ### `server/gateway.py` New REST endpoint: - `POST /api/webhook/gitea` — receives raw Gitea webhook payload - Validates `X-Gitea-Event` header for event type - Translates to Matrix messages: - `push` → `bark` (commit message) + `agent_state:working` - `pull_request.opened` → `bark` + `agent_behavior:inspect` - `pull_request.closed+merged` → `bark` (celebration) + `scene_add` (merge artifact) - `issues.opened` → `bark` + `agent_behavior:place` (issue artifact) - `issue_comment.created` → `bark` (comment excerpt) - Broadcasts translated messages to all WS clients - Optional: `X-Gitea-Secret` validation ### `server/webhooks.py` (NEW) Webhook translator module: - `translate_push(payload) -> list[dict]` — Matrix messages for push - `translate_pr(payload) -> list[dict]` — Matrix messages for PR events - `translate_issue(payload) -> list[dict]` — Matrix messages for issue events - `translate_comment(payload) -> list[dict]` — Matrix messages for comments - Filters bot-only activity (hermes, kimi, manus) unless PR merge - Uses same bot filter list as dashboard `gitea_adapter.py` ### `PROTOCOL.md` Document `webhook_event` message type. ## Acceptance Criteria - [ ] Gateway accepts POST /api/webhook/gitea with Gitea payloads - [ ] Push events → bark with commit message + author - [ ] PR merge → bark + scene artifact - [ ] Issue opened → bark + artifact - [ ] Bot-only pushes filtered (unless PR merge) - [ ] Tests with mock webhook payloads - [ ] Gitea webhook can be configured to point at gateway URL ## Depends On Nothing — standalone addition to gateway REST API.
Author
Owner

Resolved in PR #81 (feat/automation-sprint). All tests passing.

Resolved in PR #81 (feat/automation-sprint). All tests passing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: perplexity/the-matrix#77