Skip to content

Commit 1c9ff99

Browse files
committed
ci: add workflow to automate merge dependabot
1 parent c3ec53c commit 1c9ff99

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Dependabot auto-merge
2+
on:
3+
pull_request_target:
4+
types: [review_requested]
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
packages: read
10+
11+
jobs:
12+
dependabot:
13+
runs-on: ubuntu-latest
14+
if: ${{ github.actor == 'dependabot[bot]' }}
15+
steps:
16+
- name: Dependabot metadata
17+
id: metadata
18+
uses: dependabot/[email protected]
19+
with:
20+
github-token: "${{ secrets.GITHUB_TOKEN }}"
21+
skip-commit-verification: true
22+
23+
- name: Checkout repository
24+
uses: actions/checkout@v3
25+
with:
26+
submodules: "recursive"
27+
28+
- name: Approve a PR if not already approved
29+
run: |
30+
gh pr checkout "$PR_URL"
31+
if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ];
32+
then
33+
gh pr review --approve "$PR_URL"
34+
else
35+
echo "PR already approved.";
36+
fi
37+
env:
38+
PR_URL: ${{github.event.pull_request.html_url}}
39+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
40+
41+
- name: Enable auto-merge for Dependabot PRs
42+
if: ${{ contains(github.event.pull_request.title, 'bump')}}
43+
run: gh pr merge --auto --merge "$PR_URL"
44+
env:
45+
PR_URL: ${{github.event.pull_request.html_url}}
46+
GITHUB_TOKEN: ${{secrets.RELEASE_TOKEN}}

0 commit comments

Comments
 (0)