-
Notifications
You must be signed in to change notification settings - Fork 1
36 lines (32 loc) · 1.09 KB
/
auto-merge.yml
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
name: auto-merge
on:
pull_request:
branches:
- main
jobs:
auto-merge:
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'dependabot/') ||
startsWith(github.head_ref, 'actions/')
steps:
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.AUTO_MERGE_BOT_APP_ID }}
private-key: ${{ secrets.AUTO_MERGE_BOT_PRIVATE_KEY }}
- name: Approve & enable auto-merge for Dependabot/Actions PR
run: |
gh pr review --approve "$PR_URL"
gh pr edit "$PR_URL" -t "(auto merged) $PR_TITLE"
# Retry to work around "Base branch was modified." error.
# Ref: https://github.com/cli/cli/issues/8092
for i in {1..3}; do
gh pr merge --auto --merge "$PR_URL" && exit 0
sleep 5
done
exit 1
env:
PR_URL: ${{ github.event.pull_request.html_url }}
PR_TITLE: ${{ github.event.pull_request.title }}
GH_TOKEN: ${{ steps.generate_token.outputs.token }}