This guide describes how to create, configure, and install a custom GitHub App for the OpenCode PR Reviewer service.
Using a GitHub App provides security via short-lived asymmetric installation tokens (JWT), granular repository permissions, and automated webhook event delivery.
- Prerequisites
- Step 1: Create a New GitHub App
- Step 2: General Configuration
- Step 3: Webhook Configuration
- Step 4: Repository Permissions
- Step 5: Event Subscriptions
- Step 6: Generate Private Key and Retrieve App ID
- Step 7: Install App on Your Repositories
- Troubleshooting and Verification
- A GitHub Account (Personal or Organization administrator).
- A public domain or HTTPS endpoint with an active SSL certificate for receiving webhooks (for example,
https://github.yourdomain.com).
- Navigate to:
- Personal Account: GitHub Settings > Developer Settings > GitHub Apps
- Organization Account:
https://github.com/organizations/<your-org>/settings/apps
- Click New GitHub App.
Provide the general application information:
| Field | Example Value | Description |
|---|---|---|
| GitHub App name | OpenCode AI PR Reviewer |
Unique name displayed on PR reviews. |
| Description | Automated AI Pull Request code reviewer powered by OpenCode. |
Plain text description of the application. |
| Homepage URL | https://github.com/your-org |
Organization or project URL. |
| Expire user authorization tokens | Checked | Recommended security practice. |
Configure where GitHub delivers Pull Request webhook events:
- Active: Check
Activeto enable webhook delivery. - Webhook URL: Enter your public HTTPS webhook endpoint:
https://github.yourdomain.com/webhook/github - Webhook secret: Generate a cryptographically secure random string (for example, using
openssl rand -base64 32) and paste it here. Save this value for your.envfile (WEBHOOK_SECRET). - SSL verification: Select
Enable SSL verification.
Under Permissions > Repository permissions, configure the following required access levels:
| Permission | Access Level | Rationale |
|---|---|---|
| Pull requests | Read and Write | Required to post PR reviews, standby comments, and inline code suggestions. |
| Contents | Read-only | Required to clone repository code and checkout PR branches. |
| Metadata | Read-only | Default mandatory permission for repository metadata access. |
| Issues | Read and Write | Required to manage standby status comments in the PR timeline. |
Note
All other permissions (such as Administration, Checks, Deployments) can remain set to No access.
Under Subscribe to events, select the following event:
Pull request
This subscription triggers webhook deliveries for:
opened: When a new Pull Request is created.synchronize: When new commits are pushed to an open PR.reopened: When a closed PR is reopened.ready_for_review: When a draft PR is marked ready.
- Click Create GitHub App at the bottom of the page.
- After creation, copy your App ID (for example,
123456) located in the About section. - Scroll down to the Private keys section.
- Click Generate a private key. A
.pemfile will be downloaded to your local environment. - Move the downloaded
.pemfile to the root of theopencode-pr-reviewproject directory:mv ~/Downloads/*.private-key.pem ./github-app.private-key.pem
- Set restricted file permissions:
chmod 600 github-app.private-key.pem
- On your GitHub App settings page, click Install App in the left navigation sidebar.
- Select your target account or organization.
- Choose repository access:
- All repositories: Enables automated reviews for all current and future repositories.
- Only select repositories: Choose specific repositories (for example,
my-backend,my-frontend).
- Click Install and Authorize.
- Navigate to GitHub App Settings > Advanced > Recent Deliveries.
- Review delivery logs for incoming events.
- Successful deliveries return HTTP 200 with the response payload:
{ "status": "ok", "message": "PR review job enqueued", "job_id": 1 }
If service logs report HttpError: Integration not found or Bad credentials:
- Verify that the
App IDinconfig.yamlmatches the App ID displayed on GitHub. - Verify that
github-app.private-key.pemcorresponds to the private key generated for that exact GitHub App.