← 返回
未分类 中文

PR Auto-Merge Agent

Autonomous PR merge agent. Scans repos for approved + CI-passing PRs and merges them automatically. Supports dry-run mode, squash/merge options, and min-appr...
自动PR合并代理。扫描已批准且CI通过的PR并自动合并。支持干运行模式、压缩合并选项及最小批准数。
lanxevo3 lanxevo3 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 452
下载
💾 0
安装
1
版本
#auto-merge#automation#ci-cd#github#latest#pr

概述

PR Auto-Merge Agent

Autonomous pull request merge tool. Scans GitHub repos for PRs that are approved, CI-passing, and mergeable — then merges them automatically (or reports in dry-run mode).

What It Does

  • Finds all open PRs that are: not drafts + mergeable + CI passing + approved
  • Merges them via --squash (default) or --admin --merge
  • Supports --dry-run mode to preview what WOULD be merged without making changes
  • Configurable minimum approval count
  • Pure Python stdlib + gh — zero external dependencies

Prerequisites

  • gh CLI authenticated (gh auth status)
  • Python 3.6+
  • Token must have repo scope to merge

Quick Start

# Preview what would be merged (default — safe)
python3 scripts/auto_merge.py owner/repo

# Actually merge
python3 scripts/auto_merge.py owner/repo --no-dry-run

# Require 2 approvals minimum, squash merge
python3 scripts/auto_merge.py owner/repo --min-approvals 2 --squash

# Scan multiple repos
python3 scripts/auto_merge.py owner/repo1 && python3 scripts/auto_merge.py owner/repo2

Usage as Claude Code Skill

/pr-auto-merger owner/repo --dry-run

The agent will:

  1. Fetch all open PRs from the repo via gh pr list --json
  2. Filter to approved + CI-passing + mergeable PRs
  3. Report in dry-run mode (default), or merge with --no-dry-run

Merge Criteria

A PR is merged only when ALL of these are true:

  • Not a draft (isDraft: false)
  • Mergeable (mergeable: true)
  • All required status checks passing (statusCheckRollup conclusion: SUCCESS)
  • Review decision is APPROVED
  • Has at least --min-approvals approvals (default: 1)

Output Format

Scanning owner/repo for mergeable PRs...
[DRY-RUN] Found 3 PR(s) ready to merge:
  #123 — Fix auth middleware (https://github.com/owner/repo/pull/123)
  #456 — Add caching layer (https://github.com/owner/repo/pull/456)
  #789 — Update dependencies (https://github.com/owner/repo/pull/789)

Re-run with --no-dry-run to actually merge.

GitHub Actions Integration

Drop this into a nightly cron job:

name: Nightly PR Merge
on:
  schedule:
    - cron: '0 6 * * *'
jobs:
  merge:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: |
          pip install gh
          gh auth status
          python3 scripts/auto_merge.py owner/repo --no-dry-run --min-approvals 2

Cron Agent Configuration

For OpenClaw scheduling, configure as:

{
  "task": "python3 /path/to/scripts/auto_merge.py owner/repo --no-dry-run",
  "schedule": "0 8 * * 1-5",
  "notify_on": ["failure", "merged"]
}

Architecture

  • scripts/auto_merge.py — Pure Python 3 (stdlib only)
  • Uses gh pr list --json for data fetching
  • Uses gh pr merge for actual merging
  • No pip packages, no external APIs
  • Portable: Linux, macOS, Windows (Python + gh)

License

MIT

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-03 09:59 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

Freelance Job Scraper

lanxevo3
自主自由职业工作监控代理,扫描 Hacker News招聘帖、YC 招聘板和远程工作聚合平台,获取高价值自动化与 AI 工作机会。
★ 0 📥 561

Fleet PR Agent

lanxevo3
多仓库 PR 监控与分诊代理。扫描 GitHub 仓库中的开放 PR,按时效、评审状态、CI 状态进行优先级排序,并生成结构化 Markdown 报告。
★ 0 📥 377

Bounty Hunter Agent

lanxevo3
自动扫描 GitHub、Algora、Opire 的赏金任务,按报酬和竞争程度评分并排序,可自动提交 PR。
★ 0 📥 365