Skip to content

Commit

Permalink
add PR auto-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Oct 2, 2023
1 parent bf7a302 commit 75280f4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#approve-a-pull-request
# https://github.com/dependabot/fetch-metadata/#enabling-auto-merge
name: Dependabot auto-merge
on: pull_request_target

permissions:
contents: write
pull-requests: write

defaults:
run:
shell: bash

jobs:
dependabot:
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
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 --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 comments on commit 75280f4

Please sign in to comment.