feat(ci): replace opencode review with PR-Agent
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Canceled after 45s
PR Check / Secret scan (gitleaks) (pull_request) Canceled after 0s
PR Check / Dependency audit (pull_request) Canceled after 0s
PR Check / Dockerfile lint (droast) (pull_request) Canceled after 0s
PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Canceled after 45s
PR Check / Secret scan (gitleaks) (pull_request) Canceled after 0s
PR Check / Dependency audit (pull_request) Canceled after 0s
PR Check / Dockerfile lint (droast) (pull_request) Canceled after 0s
Run PR-Agent as a pinned webhook server on the Gitea Docker network and review on PR open plus slash commands. The per-PR opencode installer and verdict-posting step are removed. The server-side .env stays outside the repository; deploy/pr-agent/ holds the compose definition and operator notes.
This commit is contained in:
1 parent
9ecf504843
commit
c626cc9c1d
11 files changed
+251
-236
No files matched your search
@@ -0,0 +1,25 @@
|
||||
# Copy to .env on server0 and fill in; never commit .env.
|
||||
# chmod 600 .env
|
||||
|
||||
CONFIG__GIT_PROVIDER=gitea
|
||||
|
||||
# The API is reached over the Docker network; links in comments use the
|
||||
# public URL instead.
|
||||
GITEA__URL=http://gitea:3000
|
||||
GITEA__WEB_URL=https://git.noelsabia.dev
|
||||
|
||||
# Bot user pr-agent, scoped token (read:repository, write:issue, read:user).
|
||||
# Not the admin account and not a workflow secret.
|
||||
GITEA__PERSONAL_ACCESS_TOKEN=
|
||||
|
||||
# Secret configured on the Gitea webhook. Required: the server rejects
|
||||
# unsigned webhooks with HTTP 403.
|
||||
GITEA__WEBHOOK_SECRET=
|
||||
|
||||
# OpenCode Go exposes an OpenAI-compatible chat-completions endpoint, so
|
||||
# PR-Agent reaches it through its openai provider with a custom base URL.
|
||||
CONFIG__MODEL=openai/glm-5.3-flash
|
||||
CONFIG__FALLBACK_MODELS=["openai/glm-5.3"]
|
||||
CONFIG__CUSTOM_MODEL_MAX_TOKENS=128000
|
||||
OPENAI__API_BASE=https://opencode.ai/inference/go/openai/v1
|
||||
OPENAI__KEY=
|
||||
@@ -0,0 +1,53 @@
|
||||
# PR-Agent for Gitea
|
||||
|
||||
PR-Agent runs as a webhook server next to Gitea on `server0`. Gitea sends
|
||||
pull-request and comment events over the `gitea_gitea` Docker network; the
|
||||
endpoint is not published to the internet.
|
||||
|
||||
| Piece | Value |
|
||||
|---|---|
|
||||
| Image | `pragent/pr-agent:0.49.0-gitea_app` |
|
||||
| Container | `pr-agent` |
|
||||
| Webhook URL, from Gitea | `http://pr-agent:3000/api/v1/gitea_webhooks` |
|
||||
| Config | `/home/noel/self-hosted/pr-agent/.env` (mode 600) |
|
||||
| Logs | `docker logs -f pr-agent` |
|
||||
| Upgrade | bump the image tag, then `docker compose up -d` in this directory |
|
||||
|
||||
## Gitea side
|
||||
|
||||
1. The bot user `pr-agent` is a collaborator on `CV_Website/CV_Site_Nuxt` with
|
||||
write permission. Its personal access token is scoped to
|
||||
`read:repository`, `write:issue` and `read:user`.
|
||||
2. The repository webhook sends `push`, `issues`, `pull_request` and
|
||||
`issue_comment` events, with JSON content type and the shared secret.
|
||||
3. Gitea's `[webhook] ALLOWED_HOST_LIST` includes `private:3000`. Without it,
|
||||
Gitea's default egress policy refuses webhook deliveries to private
|
||||
addresses, including the Docker network.
|
||||
|
||||
## AI model
|
||||
|
||||
The agent uses OpenCode Go's OpenAI-compatible endpoint:
|
||||
|
||||
```text
|
||||
model openai/glm-5.3-flash
|
||||
fallback openai/glm-5.3
|
||||
api base https://opencode.ai/inference/go/openai/v1
|
||||
```
|
||||
|
||||
`CONFIG__CUSTOM_MODEL_MAX_TOKENS` tells PR-Agent the context limit, because
|
||||
the model is not in its token table. The effective review budget is still
|
||||
capped by PR-Agent's default `config.max_model_tokens` of 32000.
|
||||
|
||||
## First check
|
||||
|
||||
Open a pull request in `CV_Website/CV_Site_Nuxt`. The server runs `/describe`
|
||||
and `/review` on open/reopen; comment commands such as `/review`, `/improve`
|
||||
and `/ask` are handled from the PR conversation. If nothing appears:
|
||||
|
||||
```sh
|
||||
docker compose logs --tail=100 pr-agent
|
||||
```
|
||||
|
||||
A `403` in the Gitea webhook delivery log means the secret does not match or
|
||||
`ALLOWED_HOST_LIST` is still missing; a `401` from PR-Agent means the
|
||||
signature header and secret disagree.
|
||||
@@ -0,0 +1,38 @@
|
||||
# PR-Agent webhook server for the self-hosted Gitea instance.
|
||||
#
|
||||
# Runs on the existing gitea_gitea network and publishes no ports. Gitea
|
||||
# reaches it as http://pr-agent:3000/api/v1/gitea_webhooks, so the webhook
|
||||
# endpoint is never internet-facing. Gitea still publishes comment links with
|
||||
# its own ROOT_URL (https://git.noelsabia.dev).
|
||||
#
|
||||
# Deployed by hand on server0 from /home/noel/self-hosted/pr-agent; see the
|
||||
# README next to this file.
|
||||
|
||||
services:
|
||||
pr-agent:
|
||||
image: pragent/pr-agent:0.49.0-gitea_app
|
||||
container_name: pr-agent
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
PORT: "3000"
|
||||
# Importing the app costs roughly 250 MB. Two workers leave headroom on
|
||||
# the 3.8 GB host that also runs Gitea, its runner and a web app.
|
||||
GUNICORN_WORKERS: "2"
|
||||
mem_limit: 1g
|
||||
networks:
|
||||
- gitea
|
||||
healthcheck:
|
||||
# The server has no HTTP health route; an open TCP socket is enough to
|
||||
# distinguish a running gunicorn master from a crashed container.
|
||||
test: ["CMD", "python", "-c", "import socket; socket.create_connection(('127.0.0.1', 3000), 3).close()"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
|
||||
networks:
|
||||
gitea:
|
||||
external: true
|
||||
name: gitea_gitea
|
||||
Reference in new issue
Block a user