Skip to content

Commit 656a502

Browse files
committed
ci: add dependabot auto-merge workflow for patch and minor updates
Auto-approves and enables auto-merge (squash) for dependabot PRs that are patch or minor version bumps. Major version bumps still require manual review. Note: requires "Allow auto-merge" to be enabled in repo settings.
1 parent 805ac59 commit 656a502

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Dependabot Auto-Merge
2+
3+
on: pull_request
4+
5+
permissions:
6+
contents: write
7+
pull-requests: write
8+
9+
jobs:
10+
dependabot:
11+
runs-on: ubuntu-latest
12+
if: github.actor == 'dependabot[bot]'
13+
steps:
14+
- name: Fetch Dependabot metadata
15+
id: metadata
16+
uses: dependabot/fetch-metadata@v2
17+
with:
18+
github-token: '${{ secrets.GITHUB_TOKEN }}'
19+
20+
- name: Auto-approve patch and minor updates
21+
if: steps.metadata.outputs.update-type != 'version-update:semver-major'
22+
run: gh pr review --approve "$PR_URL"
23+
env:
24+
PR_URL: ${{ github.event.pull_request.html_url }}
25+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Enable auto-merge for patch and minor updates
28+
if: steps.metadata.outputs.update-type != 'version-update:semver-major'
29+
run: gh pr merge --auto --squash "$PR_URL"
30+
env:
31+
PR_URL: ${{ github.event.pull_request.html_url }}
32+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)