Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Add auto-merge capabilities for dependabot
Browse files Browse the repository at this point in the history
  • Loading branch information
yonatankarp committed Mar 7, 2022
1 parent 9599947 commit d65fc62
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "daily"
labels:
- "type: dependency-upgrade"
- "relates-to: build"
- "dependencies"
- "build"

# Maintain dependencies for Gradle
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"
interval: "daily"
labels:
- "type: dependency-upgrade"
- "relates-to: build"
- "dependencies"
- "build"
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,32 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "./build/reports/jacoco/jacocoTestReport.xml"

dependabot_auto_merge:
if: ${{ github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest
needs: ci
steps:
# If the PR is created by Dependabot run additional steps
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Approve a Dependabot PR
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' ||
steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
# Approving the PR and waiting for 5 sec to let GitHub UI to reflect the changes
run: gh pr review --approve "$PR_URL" && sleep 5
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.REVIEWER_GITHUB_TOKEN }}

- name: Enable auto-merge for Dependabot PRs
if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' ||
steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
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 d65fc62

Please sign in to comment.