A GitHub Action that automatically merges PRs with a configurable title prefix after a specified time period.
- Automatically merges PRs after a configurable waiting period
- Targets specific branches for auto-promotion
- Only merges PRs with a specific title prefix
- Ensures all required checks have passed before merging
Add this action to your repository by creating a workflow file (e.g., .github/workflows/auto-promote.yml):
name: Auto Promote PRs
on:
schedule:
- cron: '0 */6 * * *' # Runs every 6 hours
workflow_dispatch: # Allows manual triggering
jobs:
auto-promote:
runs-on: ubuntu-latest
steps:
- name: Auto Merge Promotion PRs
uses: your-org/auto-promote@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}| Parameter | Description | Required | Default |
|---|---|---|---|
github-token |
GitHub token for API access | Yes | N/A |
threshold-days |
Number of days before PRs are auto-merged | No | 7 |
target-branches |
Comma-separated list of branches to target for auto-merge | No | staging,production |
title-prefix |
The prefix to look for in PR titles | No | [Promotion] |
name: Auto Merge Promotion PRs
on:
schedule:
# Runs at 9:00 UTC (10:00 CET) on Monday-Friday
- cron: '0 9 * * 1-5'
workflow_dispatch: # Allow manual triggering
jobs:
auto-merge:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Auto Merge Promotion PRs
uses: beekpr/auto-merge-promotions-action@master
with:
github-token: ${{ secrets.BKPR_GC_GH_ACTIONS_TOKEN }}
threshold-days: '7'
target-branches: 'staging,production'
title-prefix: '[AutoPromote]'- The action scans all open PRs in your repository
- It filters PRs that:
- Start with the configured title prefix
- Target one of the specified branches
- Have been open for longer than the threshold days
- Have all required checks passing
- Eligible PRs are automatically merged
To create a PR that will be auto-promoted:
- Create a PR targeting one of the branches in
target-branches - Add the prefix (e.g.,
[Promotion]) to the PR title - Wait for the configured threshold period
- Ensure all checks are passing
The PR will be automatically merged once all conditions are met.