Skip to content

feat(workflows): reusable auto-arm-merge workflow#7

Open
chitcommit wants to merge 2 commits into
mainfrom
feat/auto-arm-merge
Open

feat(workflows): reusable auto-arm-merge workflow#7
chitcommit wants to merge 2 commits into
mainfrom
feat/auto-arm-merge

Conversation

@chitcommit

@chitcommit chitcommit commented Jun 4, 2026

Copy link
Copy Markdown
Member

Summary

Adds .github/workflows/auto-arm-merge.yml as a reusable workflow that arms gh pr merge --auto --squash --delete-branch on every non-draft PR in any consuming repo.

Adoption — one-liner for any ChittyOS repo

Drop this at .github/workflows/auto-arm-merge.yml in the target repo:

name: Auto-Arm Merge
on:
  pull_request:
    types: [opened, ready_for_review, reopened]
jobs:
  arm:
    uses: chittyfoundation/.github/.github/workflows/auto-arm-merge.yml@main

Requires repo settings: Allow auto-merge + Automatically delete head branches + a ruleset gating merge on required checks.

Skip conditions (PR is left alone)

  • Draft PRs (pull_request.draft == true)
  • Authors dependabot[bot], renovate[bot] (their own auto-merge logic)
  • Titles starting with WIP, [WIP], Draft:, DO NOT MERGE
  • Forks (token lacks write on head ref — gracefully no-ops)

Opt out per-PR

Mark draft, or prefix title with WIP / [WIP] / Draft: / DO NOT MERGE.

Rollout

Initial callers in follow-up PRs:

  • chittyapps/chittyfinance
  • chittyfoundation/chittyschema

Wider rollout is a separate task.

Test plan

  • Merge this PR
  • Verify caller PRs in chittyfinance + chittyschema arm auto-merge on open
  • Confirm drafts are skipped

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Added an automated pull-request auto-merge workflow with a configurable merge method (default: squash).
    • Workflow skips drafts, common WIP/DO NOT MERGE titles, bot-authored PRs and forked PRs.
    • Adds concurrency to avoid duplicate runs and improved handling/reporting for merge, permission, and ruleset errors.

Reusable workflow that arms 'gh pr merge --auto --squash --delete-branch'
on every non-draft PR. Consumed via:

  jobs:
    arm:
      uses: chittyfoundation/.github/.github/workflows/auto-arm-merge.yml@main

Skips drafts, dependabot/renovate, WIP-titled PRs, and forks. Relies on
repo ruleset to gate merge on required checks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: de33b1d0-451a-4c41-8567-91c16ddf3554

📥 Commits

Reviewing files that changed from the base of the PR and between b9defb7 and f91edb5.

📒 Files selected for processing (1)
  • .github/workflows/auto-arm-merge.yml

📝 Walkthrough

Walkthrough

Adds a reusable GitHub Actions workflow that arms auto-merge for eligible PRs, exposes a merge-method input (default: squash), restricts permissions to pull-requests: write, filters PRs (no drafts/forks/dependabot/renovate/title guards), and uses gh pr merge --auto with guarded error handling.

Changes

Auto-Merge Workflow Setup

Layer / File(s) Summary
Documentation and overview
.github/workflows/auto-arm-merge.yml
Adds top-of-file documentation explaining purpose, usage, skip conditions, and required repo settings.
Workflow contract and inputs
.github/workflows/auto-arm-merge.yml
Introduces workflow_call with merge-method input (guidance on allowed values) and sets permissions to pull-requests: write.
Job gating and concurrency
.github/workflows/auto-arm-merge.yml
Defines arm job with concurrency per PR and an if gate to skip drafts, dependabot/renovate authors, and fork PRs (requires PR head repo equals repo).
Shell step: validation, arming, and error handling
.github/workflows/auto-arm-merge.yml
Implements script that checks gh presence, sanitizes merge-method to `squash

Sequence Diagram

sequenceDiagram
  participant Runner
  participant Shell
  participant GH_CLI
  participant GitHubAPI

  Runner->>Shell: start arm job
  Shell->>GH_CLI: validate gh
  Shell->>GH_CLI: sanitize merge-method
  Shell->>GH_CLI: run gh pr merge --auto --delete-branch
  GH_CLI->>GitHubAPI: request enable auto-merge
  GitHubAPI-->>GH_CLI: respond (enabled / not mergeable / error)
  GH_CLI-->>Shell: return stdout/stderr
  Shell->>Runner: exit 0 for benign cases or emit ::error:: and fail for config/auth/ruleset failures
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped to the runner, whiskers all keen,
I taught it to merge when the PR looks clean.
Squash, merge, or rebase — I pick with a twitch,
Then tidy the branch with a swift little switch.
Hooray for neat merges! 🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(workflows): reusable auto-arm-merge workflow' clearly and concisely summarizes the main change: adding a new reusable workflow for auto-arming merge on pull requests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/auto-arm-merge

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/auto-arm-merge.yml:
- Around line 5-18: Update the pull_request trigger types in the consuming
workflow so title edits re-run the reusable workflow: add "edited" to the types
list alongside "opened", "ready_for_review", and "reopened" in the workflow
header (the section that currently lists pull_request types) so the Auto-Arm
Merge logic will re-evaluate when a PR title is changed (e.g., removing a
WIP/Draft prefix).
- Around line 29-34: The workflow lets an arbitrary merge-method string through
and masks gh pr merge failures by converting errors into a warning + exit 0; add
a validation step that checks the inputs.merge-method value against the allowed
set ("squash","merge","rebase") and fails fast (exit non-zero) if invalid,
locate the input name merge-method and add the check in the job before running
gh pr merge; remove the masking logic that downgrades gh pr merge failures to
success (remove any || true, continue-on-error: true or step that always sets
exit 0) so gh pr merge returns a failing job on real errors, update any warning
text that incorrectly references forks to reflect that fork PRs are already
excluded, and add pull_request.edited to the workflow trigger set so
title-prefix opt-out toggles work when PR titles are edited.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7266bd87-dea3-415a-a41d-12c467376dad

📥 Commits

Reviewing files that changed from the base of the PR and between 8cd6fe0 and b9defb7.

📒 Files selected for processing (1)
  • .github/workflows/auto-arm-merge.yml

Comment on lines +5 to +18
# name: Auto-Arm Merge
# on:
# pull_request:
# types: [opened, ready_for_review, reopened]
# jobs:
# arm:
# uses: chittyfoundation/.github/.github/workflows/auto-arm-merge.yml@main
#
# Skip conditions (PR is left alone):
# - draft PRs
# - authors: dependabot[bot], renovate[bot] (they have their own auto-merge logic)
# - title starts with: WIP, [WIP], Draft:, DO NOT MERGE
# - PRs from forks (GITHUB_TOKEN lacks write on the head ref; we no-op gracefully)
#

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

When a reusable workflow is called from a pull_requestworkflow, does subscribing the caller to theedited activity type trigger the called workflow again with the updated PR title?

💡 Result:

Yes, subscribing the caller workflow to the pull_request activity type edited will trigger the called (reusable) workflow again when a pull request title is updated [1][2][3]. When you define a reusable workflow, it is executed by a caller workflow [4]. If the caller workflow is configured to trigger on the pull_request event with the edited activity type, GitHub Actions will initiate a new workflow run whenever that activity occurs [5][6][7]. Because the reusable workflow is called within a job in that caller workflow, the reusable workflow will also be invoked as part of that new run [4][1]. Key details to keep in mind: 1. Configuration: By default, the pull_request event only triggers on opened, synchronize, and reopened activity types [5][6][8]. To capture title or body changes, you must explicitly include edited in your types configuration: on: pull_request: types: [opened, synchronize, edited] 2. Workflow Behavior: Every time the event occurs, a new workflow run is created [6][7]. If your reusable workflow performs actions (like commenting on the PR or deploying), it will execute these actions again [1]. 3. Common Issue: Users often find that enabling the edited activity type causes unnecessary workflow runs [2]. If you only want to trigger the workflow for specific types of edits (e.g., only when the title changes, rather than the body), you will need to add conditional logic (if statements) within your jobs to check the event context and decide whether to proceed or skip execution [9][2][10].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

ls -la .github/workflows || true
sed -n '1,120p' .github/workflows/auto-arm-merge.yml

Repository: chittyfoundation/.github

Length of output: 3400


Add edited to the caller pull_request types if the WIP/title opt-out should be reversible.

The reusable workflow’s if: skips based on the current PR title; since the consuming example only triggers on opened, ready_for_review, and reopened, removing a WIP/Draft prefix via title edit won’t re-invoke the workflow.

Suggested change
 #   on:
 #     pull_request:
-#       types: [opened, ready_for_review, reopened]
+#       types: [opened, edited, ready_for_review, reopened]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/auto-arm-merge.yml around lines 5 - 18, Update the
pull_request trigger types in the consuming workflow so title edits re-run the
reusable workflow: add "edited" to the types list alongside "opened",
"ready_for_review", and "reopened" in the workflow header (the section that
currently lists pull_request types) so the Auto-Arm Merge logic will re-evaluate
when a PR title is changed (e.g., removing a WIP/Draft prefix).

Comment thread .github/workflows/auto-arm-merge.yml
@chitcommit chitcommit enabled auto-merge (squash) June 4, 2026 05:45
…guards

Critical:
- Drop contents:write from permissions (auto-merge only needs pull-requests:write)
- Classify gh pr merge stderr instead of blanket exit 0 (surface auth/method/config drift)

Important:
- Add job-level concurrency to collapse opened+ready_for_review duplicates
- Validate merge-method input against squash|merge|rebase allowlist
- Preflight check that gh is installed on the runner
- Move WIP/Draft/DO-NOT-MERGE title check into the step using bash regex with
  a boundary class so WIPER/WIPE/WIPED no longer false-match

Doc:
- Rewrite header to reflect fork PRs are excluded at trigger level, not via no-op
- Inline rationale next to permissions, concurrency, and the regex boundary

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant