This repository has been archived on 2026-07-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
gitea-codex/docs/webhook-setup.md
T
Space-Banane f19b271642
ci / test (pull_request) Successful in 1m54s
ci / publish (pull_request) Has been skipped
feat. rebuild service in Go
Rebuild the Gitea Codex review bot from the product contract with a Go HTTP service, durable SQL queue, typed Gitea client, isolated runner, and deployment updates.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-12 21:51:01 +02:00

54 lines
2.5 KiB
Markdown

# Webhook setup
The Go service accepts signed Gitea webhooks at:
- `POST /webhook/gitea`
It processes only `issue_comment` and `pull_request_comment` events. The handler verifies the exact raw request body with HMAC-SHA256 using `GITEA_WEBHOOK_SECRET`, enforces `ALLOWED_REPOS`, ignores bot-authored comments, and queues recognized `@codex` commands.
## Configure Gitea
1. Deploy the service at a URL reachable by Gitea, for example `https://bot.example.com/webhook/gitea`.
2. Set the same random secret in Gitea and `GITEA_WEBHOOK_SECRET`.
3. Configure either an instance/global webhook or one repository webhook per target repository.
4. Use JSON content type and enable only Issue comment and Pull request comment events.
5. Add every allowed `owner/repository` to `ALLOWED_REPOS`.
6. Test the webhook from Gitea, then check `GET /healthz`.
`WEBHOOK_MODE=global` or `WEBHOOK_MODE=repo` is a deployment label; webhook provisioning remains an administrator responsibility.
## Environment
Required values are `GITEA_BASE_URL`, `GITEA_TOKEN`, `GITEA_BOT_USERNAME`, `GITEA_WEBHOOK_SECRET`, `ALLOWED_REPOS`, and either `DATABASE_URL` or the `DB_*` values. API-key Codex mode also requires `OPENAI_API_KEY`.
The recommended local development database is SQLite:
```dotenv
DATABASE_URL=sqlite://./gitea-codex.db
```
Production deployments should use MariaDB and a token with only the Gitea permissions needed to read pull requests/files and create comments. Keep the runner image pinned to a reviewed digest and treat review execution as untrusted code execution.
## Command examples
```text
@codex review
@codex review security
@codex review performance --full
@codex review tests
@codex rerun
@codex explain
@codex ignore
@codex help
```
Commands must begin the comment. Inline mentions in ordinary discussion text are intentionally ignored for compatibility. `@codex fix` is not supported.
## Security notes
- Invalid signatures return HTTP 401.
- Fork pull requests are skipped unless `ALLOW_UNTRUSTED_FORKS=true`.
- The bot launches review containers through the host Docker API; secure the Docker socket and runner host accordingly.
- The review container receives credentials required by the configured Codex/Gitea workflow. Use least-privilege credentials, restrict network access, and do not use unpinned images in production.
- Health detail endpoints expose bounded job metadata. Put them behind an internal network or reverse-proxy authentication if repository names and review errors are sensitive.