GitHub Action
AutomergePR
This action is intended to be used in tandem with a CI workflow. This workflow requires a github token with read/write access to all the repositories it will be tracking
Any PRs that meet the following criteria will be automerged:
- PR is open
- PR is mergeable
- PR is passing test
- PR is approved by at least one reviewer
- PR is up-to-date with the base branch
Any PR with the following criteria will be updated and test will be run before merging:
- PR is open
- PR is approved
- PR is passing PR Tests
- PR is out-of-date
This example workflow will run every 20 minutes and will automerge PRs for tracked repositories in the organization.
This workflow is recommended for setup in a CI/CD Devops dedicated repostiory.
For the example a JSON file called automerge.json
contains a list of repositories to track PR status for merging/updates.
The JSON file should be in the following format:
[
"repo1",
"repo2",
"repo3"
]
In a workflow we will call .github/workflows/automerge.yml
.
The workflow will run as many jobs in parallel as possible.
name: Example Automerge Workflow
on:
workflow_dispatch:
schedule:
- cron: '*/20 * * * *'
jobs:
list:
name: 'List Repos'
runs-on: [ubuntu-latest]
outputs:
matrix: ${{ steps.list.outputs.value }}
steps:
- name: 'Check out devops repo'
uses: actions/[email protected]
- id: list
name: 'List automerge repos'
run: echo "value=$(cat test/automerge.json | tr -d '\n')" >> $GITHUB_OUTPUT
automerge-test:
name: 'Automerge'
runs-on: [ubuntu-latest]
needs: list
strategy:
fail-fast: false
matrix:
value: ${{fromJson(needs.list.outputs.matrix)}}
steps:
- name: 'Automerge runtimeverification/${{ matrix.value }}'
uses: ./ # This uses the action in the root directory
with:
org: 'runtimeverification' # As long as the token you use has access, any org is valid here
repo: ${{ matrix.value }}
token: ${{ secrets.GITHUB_PAT }}
If less CI Pressure is desired, the workflow can be modified to run on sequentially
name: Test Workflow
on:
workflow_dispatch:
schedule:
- cron: '*/20 * * * *'
...
...
...
automerge-test:
name: 'Automerge'
runs-on: [ubuntu-latest]
needs: list
strategy:
fail-fast: false
max-parallel: 1 # Or any integer up to 256 set by github actions run limit.
matrix:
value: ${{fromJson(needs.list.outputs.matrix)}}
steps:
...
...
Checkout the repository you wish to run automerge on to a local directory.
git clone [email protected]:org/automerge.git
cd automerge
Now you need to run the command from this new directory
$(pwd)/../src/automerge.py --org runtimeverification --repo automerger-test --dry-run
Recommended to first review the actions before running without. Then remove the --dry-run
flag to run the action.