Skip to content

Repository files navigation

Merge Queue

A standalone GitHub App that provides merge queue functionality for any repository. Coordinates PR merges to prevent merge conflicts and ensure CI passes before merging.

Features

  • Automated queue processing - PRs are merged in order, one at a time
  • Auto-rebase - Automatically updates PRs with latest base branch before merging
  • CI verification - Waits for status checks to pass before merging
  • Multiple triggers - Queue via label (merge-queue) or comment (/merge)
  • Per-repo settings - Configure merge method, timeouts, and triggers per repository
  • Audit trail - Full event history for compliance
  • Multi-repo support - One installation works across all your repos

Quick Start

1. Create a GitHub App

  1. Go to GitHub Settings > Developer settings > GitHub Apps > New GitHub App

  2. Configure:

    • Name: Your Merge Queue
    • Webhook URL: https://your-domain.com/webhooks/github
    • Webhook Secret: Generate a secure secret
    • Permissions:
      • Repository: Contents (Read & Write), Pull requests (Read & Write), Commit statuses (Read)
      • Organization: Members (Read)
    • Events: Pull request, Issue comment, Installation
  3. Generate a private key and download it

2. Deploy the Service

# Environment variablesexport DATABASE_URL="postgres://user:pass@host:5432/merge_queue"export GITHUB_APP_ID="123456"export GITHUB_PRIVATE_KEY_PATH="./private-key.pem"export GITHUB_WEBHOOK_SECRET="your-webhook-secret"# Run
go build -o merge-queue ./cmd/server
./merge-queue

3. Install the App

Install your GitHub App on the organizations/repos you want to use it with.

Usage

Add PR to Queue

Via Label: Add the merge-queue label to a PR

Via Comment: Comment /merge on the PR

Via API:

curl -X POST https://your-domain.com/api/v1/queue \
-H "Content-Type: application/json" \
-d '{"owner": "org", "repo": "repo", "pr_number": 123}'

View Queue

curl "https://your-domain.com/api/v1/queue?owner=org&repo=repo"

Configure Settings

curl -X PUT https://your-domain.com/api/v1/settings \
-H "Content-Type: application/json" \
-d '{ "owner": "org", "repo": "repo", "enabled": true, "merge_method": "squash", "require_ci_pass": true, "auto_rebase": true, "trigger_label": "merge-queue", "trigger_comment": "/merge" }'

API Reference

EndpointMethodDescription
/healthzGETHealth check
/webhooks/githubPOSTGitHub webhook receiver
/api/v1/queueGETGet queue for a repo
/api/v1/queuePOSTAdd PR to queue
/api/v1/queue/{id}DELETERemove from queue
/api/v1/queue/{id}/retryPOSTRetry failed item
/api/v1/settingsGETGet repo settings
/api/v1/settingsPUTUpdate repo settings
/api/v1/eventsGETGet queue events
/api/v1/installationsGETList installations

Configuration

Environment Variables

VariableRequiredDescription
DATABASE_URLYesPostgreSQL connection string
GITHUB_APP_IDYesGitHub App ID
GITHUB_PRIVATE_KEYYes*PEM content (or use path)
GITHUB_PRIVATE_KEY_PATHYes*Path to PEM file
GITHUB_WEBHOOK_SECRETNoWebhook signature secret
PORTNoServer port (default: 8080)

*One of GITHUB_PRIVATE_KEY or GITHUB_PRIVATE_KEY_PATH is required.

Per-Repository Settings

SettingDefaultDescription
enabledtrueEnable/disable queue for repo
merge_methodmergemerge, squash, or rebase
require_ci_passtrueWait for CI before merge
auto_rebasetrueUpdate branch before merge
delete_branch_on_mergetrueDelete PR branch after merge
max_queue_size50Max items in queue
ci_timeout_minutes60CI wait timeout
trigger_labelmerge-queueLabel to trigger queue
trigger_comment/mergeComment to trigger queue

Queue Status Flow

queued → processing → rebasing → waiting_ci → merging → merged
↓ ↓ ↓ ↓
failed failed failed failed

License

MIT

Test 1770522805

About

Standalone merge queue GitHub App for coordinating PR merges

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages