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: ubiquibot/automated-merging
name: automated-merging
id: automated-merging
description: "Automatically merge pull-requests."
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
repos:
monitor: ["ubiquibot/automated-merging"]
ignore: ["ubiquibot/automated-merging"]
allowedReviewerRoles: ["COLLABORATOR", "MEMBER", "OWNER"]
bun 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"
}
Fine-grained repository control:
repos: {
monitor: string[]; // Repositories to watch
ignore: string[]; // Repositories to exclude
}
Role-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-sdk
base 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
-
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
- 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.