-
Notifications
You must be signed in to change notification settings - Fork 1
40 lines (33 loc) · 1.28 KB
/
auto-merge-dependabot.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
37
38
39
40
name: Auto Merge Dependabot PRs
on:
pull_request:
types: [opened, synchronize]
permissions: write-all
jobs:
merge:
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install gh
run: |
latest_version=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
download_url="https://github.com/cli/cli/releases/download/v${latest_version}/gh_${latest_version}_linux_amd64.tar.gz"
wget $download_url
tar -xvf gh_${latest_version}_linux_amd64.tar.gz
sudo mv gh_${latest_version}_linux_amd64/bin/gh /usr/local/bin
rm gh_${latest_version}_linux_amd64.tar.gz
rm -rf gh_${latest_version}_linux_amd64
- name: Configure Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: Merge PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# 获取 PR 号码
PR_NUMBER=$(jq -r .pull_request.number < "$GITHUB_EVENT_PATH")
# 合并 PR
gh pr merge $PR_NUMBER --auto --merge --delete-branch