Skip to content

Commit 52a0e40

Browse files
committed
Allow auto-merging dependabot PRs
1 parent cd81058 commit 52a0e40

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

.github/workflows/dependabot.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Dependabot auto-merge
2+
on: pull_request
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'mendix/cf-mendix-buildpack'
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Dependabot metadata
15+
id: dependabot-metadata
16+
uses: dependabot/fetch-metadata@v2
17+
with:
18+
github-token: "${{ secrets.GITHUB_TOKEN }}"
19+
20+
- name: Approve a PR if not already approved
21+
run: |
22+
gh pr checkout "$PR_URL"
23+
if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ];
24+
then gh pr review --approve "$PR_URL"
25+
else echo "PR already approved, skipping additional approvals to minimize emails/notification noise.";
26+
fi
27+
env:
28+
PR_URL: ${{github.event.pull_request.html_url}}
29+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
30+
31+
- name: Enable auto-merge for Dependabot PRs
32+
if: steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor'
33+
run: gh pr merge --auto --merge "$PR_URL"
34+
env:
35+
PR_URL: ${{github.event.pull_request.html_url}}
36+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)