Gitea Integration
Run a Gitea webhook server
-
In Gitea create a new user and give it write access to the intended repositories, either as a collaborator or through an organization team. See Gitea repository permissions.
-
For the user from step 1. generate a personal access token under User Settings → Applications, with
write:repositoryandwrite:issuescopes for reading pull requests and publishing descriptions, reviews, comments, and labels. See Gitea API token permissions. -
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.gitcd pr-agent -
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. Secrets can also be provided through a mounted
.secrets.tomlfile. The supported secrets files are excluded from the Docker build context; do not bake secrets into the image.CONFIG__GIT_PROVIDER=giteaGITEA__PERSONAL_ACCESS_TOKEN=<personal_access_token>GITEA__WEBHOOK_SECRET=<webhook_secret>GITEA__URL=https://gitea.com # Or self host# GITEA__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=false# GITEA__SSL_CA_CERT=/path/to/cacert.pem # Only for a custom CA certificateNote: 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 repository. 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 pull request and pull request comment events. To run commands after new commits, also enable pull request synchronization events and setgitea.handle_push_trigger = true. The server handles normalizedpull_requestandissue_commentevents, not standalonepushevents. -
Test your installation by opening a pull request or commenting on a pull 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.