Mergebot Quickstart – Self-Hosted with GitHub App¶
Follow these steps to run Mergebot ondemand against your repositories using your own GitHub App.
1. Create a GitHub App¶
- Go to Settings → Developer settings → GitHub Apps → New GitHub App.
- Fill in:
- App name: e.g.
Mergebot Self-Hosted - Webhook URL:
http://YOUR-HOST/webhook(not used in ondemand but required) - Callback URL: leave blank or placeholder (
https://example.com/unused) - Permissions (Repository level)
- Contents: Read & write
- Pull requests: Read & write
- Issues: Read & write
- Checks: Read & write (optional)
- Save, then Generate a private key → download
private-key.pem. - Install the App on the repository/org you want Mergebot to manage.
- Note the App ID (Settings page).
- Installation ID is optional – Mergebot will auto-discover it.
2. Prepare environment variables¶
export GITHUB_APP_ID=123456 # your App ID
export GITHUB_APP_PRIVATE_KEY="$(cat private-key.pem)"
# Optional – only if auto-discovery fails
# export GITHUB_APP_INSTALLATION_ID=987654
PEM formatting and CI secrets
- Provide the raw PEM (not a file path). The value should include the header/footer lines.
- Secrets work as:
- Multiline PEM (recommended): paste the full contents including line breaks.
- Single-line PEM with 'n': you can store the PEM on one line with literal 'n' newlines. Mergebot accepts both formats.
- GitHub Actions: set
GITHUB_APP_IDandGITHUB_APP_PRIVATE_KEYas repository or org secrets; the workflow examples pass them through to Docker.
You may instead set these keys in mergebot/config.yaml or .mergebot.yml:
repository:
type: github
github:
app_id: 123456
private_key: |
-----BEGIN RSA PRIVATE KEY-----
YOUR-PEM-CONTENT-HERE
-----END RSA PRIVATE KEY-----
# installation_id: 987654 # optional
3. Run Mergebot ondemand¶
Ensure your mergebot/config.yaml (or the file pointed to by CONFIG_PATH) lists the repositories under repository.projects. Then run:
CONFIG_PATH=mergebot/config.yaml mergebot ondemand
Mergebot will:
- Generate a JWT and exchange it for an installation access token.
- Analyse open pull requests for each configured project.
- Comment / approve according to your
.mergebot.yml.
Troubleshooting¶
| Symptom | Resolution |
|---|---|
GitHub App credentials missing… |
Ensure GITHUB_APP_ID and GITHUB_APP_PRIVATE_KEY are set or in config. |
Could not determine installation_id |
Pass GITHUB_APP_INSTALLATION_ID env var (see Installations page URL). |
| 401/403 errors | Check that the App is installed on the target repo and has correct permissions. |
| Private key path error | Provide full path or inline PEM via env. |
You are now ready to automate PR reviews with your self-hosted Mergebot!