Deploy PR-Agent to AWS Lambda with GitLab integration
  • Python 56%
  • HCL 25.1%
  • Shell 18.9%
Find a file
2026-06-14 21:17:55 -04:00
config feat: use pre-commit instead of linting ci, refine pr-agent config, improve safety of deploy.sh, implement CONTRIBUTING.md 2026-06-14 21:17:55 -04:00
infra feat: use pre-commit instead of linting ci, refine pr-agent config, improve safety of deploy.sh, implement CONTRIBUTING.md 2026-06-14 21:17:55 -04:00
.gitignore initial release 2026-06-14 14:03:07 -04:00
.pre-commit-config.yaml feat: use pre-commit instead of linting ci, refine pr-agent config, improve safety of deploy.sh, implement CONTRIBUTING.md 2026-06-14 21:17:55 -04:00
bun.lock initial release 2026-06-14 14:03:07 -04:00
configure_gitlab.py feat: use pre-commit instead of linting ci, refine pr-agent config, improve safety of deploy.sh, implement CONTRIBUTING.md 2026-06-14 21:17:55 -04:00
CONTRIBUTING.md feat: use pre-commit instead of linting ci, refine pr-agent config, improve safety of deploy.sh, implement CONTRIBUTING.md 2026-06-14 21:17:55 -04:00
deploy.sh feat: use pre-commit instead of linting ci, refine pr-agent config, improve safety of deploy.sh, implement CONTRIBUTING.md 2026-06-14 21:17:55 -04:00
package.json feat: use pre-commit instead of linting ci, refine pr-agent config, improve safety of deploy.sh, implement CONTRIBUTING.md 2026-06-14 21:17:55 -04:00
README.md feat: use pre-commit instead of linting ci, refine pr-agent config, improve safety of deploy.sh, implement CONTRIBUTING.md 2026-06-14 21:17:55 -04:00
ruff.toml initial release 2026-06-14 14:03:07 -04:00

PR-Agent for GitLab on AWS Lambda

This repository contains the configuration, infrastructure, and deployment scripts to run PR-Agent as an on-demand AWS Lambda function integrated with GitLab, using GLM-5 via Amazon Bedrock as the model backend.

Prerequisites

  1. AWS CLI: Authenticated with credentials that have permission to create IAM Roles, ECR repositories, Secrets Manager secrets, and Lambda functions.
  2. Docker: Running locally to build the container image.
  3. Bun: Installed for formatting and linting tools (bun run format).
  4. Python 3: To run the interactive configure_gitlab.py script.
  5. Pre-commit: Installed locally to run pre-commit quality checks.

Deployment & Setup

Step 1: Bootstrap Infrastructure and Deploy

Execute the deployment script to initialize Terraform, build the Docker image, push it to AWS ECR, and deploy the Lambda function. This will also clone the upstream PR-Agent source into pr-agent-src/ if it doesn't already exist:

./deploy.sh

This will output your API Gateway URL (preferred) and Lambda Function URL when complete.

Step 2: Register GitLab Webhooks

Create a .env file in the root of the repository. (This file is ignored by Git to keep your token secure):

GITLAB_URL=https://gitlab.com  # Or your self-hosted GitLab instance URL
GITLAB_PERSONAL_ACCESS_TOKEN=glpat-your-bots-personal-access-token
GITLAB_ADMIN_TOKEN=glpat-admin-personal-access-token

Note

The GitLab Personal Access Token requires api scope to list projects and configure webhooks automatically.

Then run the interactive configuration script to upload your GitLab credentials to Secrets Manager and register the webhook on your target projects:

python3 configure_gitlab.py

The script will list all projects you have access to. Select the indices of the projects you wish to enable (or type all), and it will create/update the webhook.

Usage (Slash Commands)

Once set up, add comments to any Merge Request in the configured projects to trigger PR-Agent:

  • /review — Full line-by-line code review with inline comments
  • /describe — Regenerate/update the MR description
  • /improve — Suggest specific code improvements
  • /ask <question> — Ask PR-Agent a question about the MR diff

Linting & Formatting (Pre-commit Hooks)

This repository uses pre-commit to ensure code quality, formatting, and validation automatically before every commit.

Setup

  1. Install pre-commit on your machine:

    brew install pre-commit
    
  2. Register the hooks in your local Git repository:

    pre-commit install
    

Once installed, the hooks will automatically run on the staged files every time you execute git commit.

Running Manually

You can manually run the hooks against all files in the repository at any time:

pre-commit run --all-files

If you need to bypass the checks for a specific commit (e.g., temporary local work), you can use:

git commit -m "your message" --no-verify