b32bf9eb82559a2fd3b953d47f2939c0874f32fd
Gitea Codex Review Bot
Webhook-driven PR review bot for Gitea.
Features
- Handles
issue_commentandpull_request_commentevents. - Verifies
X-Gitea-SignatureHMAC (sha256). - Triggers on
@codex review,@codex rerun,@codex explain,@codex fix,@codex ignore. - Ignores bot-authored comments.
- Enforces strict repository allowlist (
ALLOWED_REPOS). - Deduplicates webhook deliveries/comments in DB.
- Enforces PR cooldown for review requests.
- Uses MariaDB + SQLAlchemy + Alembic.
- Runs review jobs through ephemeral runner containers (with local fallback if Docker runtime is unavailable).
- Posts/updates one persistent PR summary comment.
- Supports repository config via
.codex-review.yml.
Endpoints
POST /webhook/giteaGET /healthz
Webhook Setup Model
This bot is designed for self-hosted deployment:
- You host this service yourself.
- A Gitea admin points webhook events to your hosted endpoint:
https://your-bot-domain/webhook/gitea
- Gitea sends
issue_commentandpull_request_commentevents to that endpoint.
Webhook configuration is manual by design.
Detailed setup instructions for both global and repository-only webhooks:
Environment
Use .env.example as template.
Required:
GITEA_BASE_URLGITEA_TOKENGITEA_BOT_USERNAMEGITEA_WEBHOOK_SECRETALLOWED_REPOSDB_HOST,DB_PORT,DB_NAME,DB_USER,DB_PASSWORD
Optional:
OPENAI_API_KEY(required whenCODEX_AUTH_MODE=api_key, optional whenCODEX_AUTH_MODE=chatgpt)OPENAI_PROJECT_IDOPENAI_ORG_IDCODEX_AUTH_MODE(api_keydefault, orchatgpt)CODEX_AUTH_JSON_PATH(custom host path toauth.json; defaults to~/.codex/auth.jsoninchatgptmode)DATABASE_URL(overrides composed DB URL)
Local Run
python -m pip install -e .[dev]
alembic upgrade head
uvicorn gitea_codex_bot.main:app --host 0.0.0.0 --port 8000
Docker Compose
# Local dev image build
docker compose -f docker-compose.dev.yml up --build
# Published image
docker compose up
CI
The workflow in .gitea/workflows/ci.yml:
- starts MariaDB service,
- runs Alembic migrations + tests,
- builds and pushes image tags to
gitea.reversed.dev/space/gitea-codexon push.
Expected secrets for publish job:
REGISTRY_USERNAMEREGISTRY_PASSWORD
Description
Languages
Python
98.7%
Shell
1%
Dockerfile
0.3%