Skip to content

Commit

Permalink
ci(github-actions): add auto approve and merge github action (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-trajanovski authored Apr 22, 2024
1 parent d48b79e commit 771d890
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/auto-merge-dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Dependabot auto approve and merge

on: pull_request

permissions:
pull-requests: write
contents: write
packages: read

jobs:
auto-approve-and-merge:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
steps:
# Extract information about the dependencies being updated by a Dependabot-generated PR
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

# NOTE: This step is only required if the repository has been configured to Require approval
# Checks if update-type is patch or minor, then approve if the PR status is not approved yet.
- name: Auto approve patch and minor updates
uses: hmarr/auto-approve-action@v4
if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor'}}

# NOTE: Requirements for merge has to be configured in the Branch protection rule page.
# To do so, go to repository > Settings > Branches > Edit
- name: Enable auto-merge for Dependabot PRs
if: ${{ contains(github.event.pull_request.title, 'bump')}}
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 771d890

Please sign in to comment.