Skip to content

Commit fa20510

Browse files
committed
chore: add automerge workflow for dependabot
1 parent 2a35336 commit fa20510

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.github/workflows/automerge.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Adapted from https://blog.somewhatabstract.com/2021/10/11/setting-up-dependabot-with-github-actions-to-approve-and-merge/
2+
name: Dependabot auto-merge
3+
4+
on: pull_request
5+
6+
permissions:
7+
pull-requests: write
8+
contents: write
9+
10+
jobs:
11+
dependabot:
12+
runs-on: ubuntu-latest
13+
# Checking the actor will prevent your Action run failing on non-Dependabot
14+
# PRs but also ensures that it only does work for Dependabot PRs.
15+
if: ${{ github.actor == 'dependabot[bot]' }}
16+
steps:
17+
# This first step will fail if there's no metadata and so the approval
18+
# will not occur.
19+
- name: Dependabot metadata
20+
id: dependabot-metadata
21+
uses: dependabot/fetch-metadata@v1
22+
with:
23+
github-token: "${{ secrets.GITHUB_TOKEN }}"
24+
25+
# Here the PR gets approved.
26+
- name: Approve a PR
27+
if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
28+
run: gh pr review --approve "${{ github.event.pull_request.html_url }}"
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
# Finally, this sets the PR to allow auto-merging for patch and minor
33+
# updates if all checks pass
34+
- name: Enable auto-merge for Dependabot PRs
35+
if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
36+
run: gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}"
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)