Gitea Integration
Run a Gitea webhook server
-
In Gitea create a new user and give it "Reporter" role for the intended group or project.
-
For the user from step 1. generate a
personal_access_tokenwithapiaccess. -
Generate a random secret for your app, and save it for later (
webhook_secret). For example, you can use:WEBHOOK_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))")The webhook secret is required: if
GITEA.WEBHOOK_SECRETis not configured, the server rejects every incoming webhook with HTTP 403. -
Clone this repository:
git clone https://github.com/the-pr-agent/pr-agent.git -
Prepare variables and secrets. Skip this step if you plan on setting these as environment variables when running the agent:
- In the configuration file/variables:
- Set
config.git_providerto "gitea"
- Set
- In the secrets file/variables:
- Set your AI model key in the respective section
- In the [Gitea] section, set
personal_access_token(with token from step 2) andwebhook_secret(with secret from step 3)
- In the configuration file/variables:
-
Build a Docker image for the app and optionally push it to a Docker repository. We'll use Dockerhub as an example:
docker build . -t pr-agent:gitea_app --target gitea_app -f docker/Dockerfile# Optional, to push it to your own Docker repository:docker tag pr-agent:gitea_app <your-registry>/pr-agent:gitea_appdocker push <your-registry>/pr-agent:gitea_app -
Set the environmental variables, the method depends on your docker runtime. Skip this step if you included your secrets/configuration directly in the Docker image.
CONFIG__GIT_PROVIDER=giteaGITEA__PERSONAL_ACCESS_TOKEN=<personal_access_token>GITEA__WEBHOOK_SECRET=<webhook_secret>GITEA__URL=https://gitea.com # Or self hostGITEA__WEB_URL=https://git.example.com # Optional: user-facing URL for links published in comments (see below)OPENAI__KEY=<your_openai_api_key>GITEA__SKIP_SSL_VERIFICATION=falseGITEA__SSL_CA_CERT=/path/to/cacert.pemNote: SSL verification can be disabled by setting
GITEA__SKIP_SSL_VERIFICATION=true, although this is not recommended.Links published in comments are built from
GITEA__WEB_URLwhen set, else fromGITEA__URLwhen it differs from the shipped default (https://gitea.com), else derived from the PR'shtml_url(which Gitea/Forgejo builds from its ownROOT_URL). SetGITEA__WEB_URLexplicitly whenGITEA__URLis an internal address users cannot browse (e.g. a Docker service name), or when the server'sROOT_URLis misconfigured. -
Create a webhook in your Gitea project. Set the URL to
http[s]://<PR_AGENT_HOSTNAME>/api/v1/gitea_webhooks, the secret token to the generated secret from step 3, and enable the triggerspush,commentsandmerge request events. -
Test your installation by opening a merge request or commenting on a merge request using one of PR Agent's commands.
-
The webhook server runs under gunicorn with multiple worker processes. See Sizing a self-hosted webhook server for the
GUNICORN_WORKERS/GUNICORN_MAX_WORKERSknobs and memory guidance — worth reading before setting a memory limit.
Incomplete pull-request files
PR-Agent stops the command when Gitea cannot supply complete, valid changed-file data, rather than analyzing a partial change set.
When CONFIG.PUBLISH_OUTPUT is enabled, PR-Agent attempts to post a PR-Agent command was not run notice with a Gitea-specific explanation. Publishing this notice is best effort; it may not appear if the provider cannot post it.
Retry the command. If the problem persists, inspect the pull request's changed files and diff in Gitea.