Skip to content

Commit

Permalink
add dependabot PR auto-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Oct 16, 2023
1 parent e1ba455 commit c4c8fc5
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: Build
on:
push:
branches-ignore: # build all branches except:
- 'dependabot/**' # prevent GHA triggered twice (once for commit to the branch and once for opening/syncing the PR)
- 'dependabot/**' # prevent GHA triggered twice (once for commit to the branch and once for opening/syncing the PR)
tags-ignore: # don't build tags
- '**'
paths-ignore:
Expand Down Expand Up @@ -124,3 +124,37 @@ jobs:
~/.m2/repository
!~/.m2/repository/com/vegardit/maven
key: ${{ steps.cache-restore.outputs.cache-primary-key }}


dependabot-pr-auto-merge:
needs: build
if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1 # https://github.com/dependabot/fetch-metadata/
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Enable auto-merge for Dependabot PRs
if: |
${{
(
steps.dependabot-metadata.outputs.package-ecosystem == 'github-actions' &&
steps.metadata.outputs.update-type == 'version-update:semver-major'
) || (
steps.dependabot-metadata.outputs.package-ecosystem == 'maven' &&
steps.metadata.outputs.update-type == 'version-update:semver-minor'
)
}}
run: |
gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 comments on commit c4c8fc5

Please sign in to comment.