Skip to content

Auto-merge Bot PRs #833

Auto-merge Bot PRs

Auto-merge Bot PRs #833

name: Auto-merge Bot PRs
permissions:
pull-requests: write
contents: write
on:
pull_request:
types: [labeled, opened, synchronize, reopened]
branches:
- main
workflow_run:
workflows: ["Test JDK 25 and Update Results"]
types:
- completed
jobs:
automerge_pr_event:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Enable auto-merge for eligible PRs (pull_request event)
if: (github.event.pull_request.user.login == 'github-actions[bot]' || github.event.pull_request.user.login == 'gounthar') && github.event.pull_request.head.repo.full_name == github.repository && contains(github.event.pull_request.labels.*.name, 'automation')
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
merge-method: squash
pull-request-number: ${{ github.event.pull_request.number }}
automerge_workflow_run:
if: github.event_name == 'workflow_run'
runs-on: ubuntu-latest
steps:
- name: Install GitHub CLI and jq
run: |
sudo apt-get update
sudo apt-get install -y gh jq
- name: Enable auto-merge for eligible PRs (workflow_run event)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for author in github-actions[bot] gounthar; do
gh pr list --state open --label automation --author "$author" --json number | jq '.[].number' | while read pr; do
gh pr merge "$pr" --auto --squash
done
done