-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (42 loc) · 1.55 KB
/
auto-merge-bot-prs.yml
File metadata and controls
47 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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