Automatically merge pull-requests based on the reviewer count, the time elapsed since the last activity, depending on the association of the pull-request author.
- plugin: ubiquity-os-marketplace/daemon-merging
with:
approvalsRequired:
collaborator: 1 # defaults to 1
contributor: 2 # defaults to 2
mergeTimeout:
collaborator: "3.5 days" # defaults to 3.5 days
contributor: "7 days" # defaults to 7 days
excludedRepos: ["owner/repo", "another-org/specific-repo"]
allowedReviewerRoles: ["COLLABORATOR", "MEMBER", "OWNER"]bun run test- Built on TypeScript with strict type checking
- Integrates with GitHub's Actions runtime environment
- Processes webhooks for 'push' and 'issue_comment.created' events
- Manages PR lifecycle through GitHub's REST API
The core logic is implemented as a plugin system that:
- Evaluates PRs against configurable rules
- Manages approval workflows
- Handles state transitions
- Processes merge operations
- GitHub Events Handler: Processes incoming webhooks for:
- Push events (for base branch updates)
- Issue comment events (for approval tracking)
- Summary Generator: Creates visual PR status reports with:
- Merge status indicators (🔵 merged, ⚫️ unmerged)
- Repository monitoring status
- Configuration overview
Configurable thresholds based on contributor status:
approvalsRequired: {
collaborator: number; // Default: 1
contributor: number; // Default: 2
}Customizable waiting periods:
mergeTimeout: {
collaborator: string; // Default: "3.5 days"
contributor: string; // Default: "7 days"
}Repositories to exclude from monitoring:
excludedRepos: string[]; // Repositories in "owner/repo" format to excludeRole-based access control:
allowedReviewerRoles: string[]; // Default: ["COLLABORATOR", "MEMBER", "OWNER"]The project uses a comprehensive type system built on TypeScript:
- Context Types: Extends
@ubiquity-os/plugin-sdkbase context - Environment Configuration: Validated through TypeBox schemas
- Plugin Settings: Strictly typed configuration options
- Event Types: Typed webhook event handling
- Bun for testing and development
- TypeScript with strict mode
- Jest for testing framework
- Runs in GitHub Actions environment
- Node.js compatibility mode
- TypeBox for runtime type validation
- Postgres-backed issue state via
DATABASE_URL - Deno app lifecycle is managed by
ubiquity-os/deno-deploy@main - Prisma DB provisioning only ensures the shared
ubiquity-os-postgresdatabase exists;DATABASE_URLstays in the GitHub environment - Collision avoidance inside the shared database is handled by project-specific tables.
- This repo intentionally uses the
daemon_merging_*table namespace.
-
Event Reception
- GitHub webhook triggers Action
- Event type and payload validated
-
Configuration Loading
- Settings loaded from yml config
- Environment variables processed
- Type validation performed
-
PR Evaluation
- Find PRs linked to the specific issue from the payload
- Author association checked
- Review counts tallied
- Time thresholds evaluated
-
Merge Processing
- Conditions verified
- Merge operation executed
- Status updated
-
Reporting
- Summary generated
- Status posted to PR
- Monitoring updates logged
This architecture ensures reliable, type-safe automated PR management with configurable rules and comprehensive status reporting.
- Purpose: Automatically merges the repository’s default branch (usually
development) intomainwhen the default branch has been inactive (no non-bot commits) for a configurable number of days. - Schedule: Runs weekly on Mondays at 06:00 UTC via GitHub Actions, and can also be triggered manually (
workflow_dispatch). See.github/workflows/auto-merge-development.yml. - Scope: Processes all repositories across configured organizations.
- Behavior:
- Skips active branches; only merges if inactivity threshold is met (default 90 days).
- If
maindoes not exist, creates it from the default branch and retries the merge. - On merge conflicts, opens an automated PR (
<defaultBranch> -> main) instead of force merging. - Includes a fork-safety guard to avoid operating on forks that have open PRs upstream.
- Configuration (env/vars):
APP_ID,APP_PRIVATE_KEY(GitHub App credentials) — from repository secrets.TARGET_ORGS(JSON array of orgs to scan) — repository variables; defaults to["ubiquity", "ubiquity-os", "ubiquity-os-marketplace", "ubiquity-research", "devpool-directory"].INACTIVITY_DAYS(number) — repository variable; defaults to90.
- Implementation: Executed by Bun via
bun run CI/src/cli.ts, which authenticates the app, lists repos, evaluates inactivity, merges default →main, and writes a job summary.