-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the dependabot approve action
Signed-off-by: Aurélien Bompard <[email protected]>
- Loading branch information
Showing
1 changed file
with
21 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,30 @@ | ||
name: Auto-approve Dependabot PRs | ||
on: | ||
schedule: | ||
- cron: "7 * * * *" | ||
workflow_dispatch: | ||
# Ref: https://blog.somewhatabstract.com/2021/10/11/setting-up-dependabot-with-github-actions-to-approve-and-merge/ | ||
|
||
name: Approve Dependabot PRs | ||
on: pull_request_target | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
jobs: | ||
auto-approve: | ||
name: Auto-approve minor and patch updates | ||
runs-on: ubuntu-latest | ||
# Checking the actor will prevent your Action run failing on non-Dependabot | ||
# PRs but also ensures that it only does work for Dependabot PRs. | ||
if: ${{ github.actor == 'dependabot[bot]' }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: koj-co/dependabot-pr-action@master | ||
# This first step will fail if there's no metadata and so the approval | ||
# will not occur. | ||
- name: Dependabot metadata | ||
id: dependabot-metadata | ||
uses: dependabot/fetch-metadata@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
approve-minor: true | ||
approve-patch: true | ||
|
||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
# Here the PR gets approved if it's not a major update | ||
- name: Approve minor and patch updates | ||
if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }} | ||
run: gh pr review --approve "$PR_URL" | ||
env: | ||
PR_URL: ${{ github.event.pull_request.html_url }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# Mergify will do the merging. |