Skip to content

Commit

Permalink
145 Automate dependabot PRs (#137)
Browse files Browse the repository at this point in the history
* dependabot merge script added

* automerge workflow updated

* update fetch-metadata version

---------

Co-authored-by: Johannes Schneider <johannes-schneider_1995@web.de>
  • Loading branch information
rnewbigging and Johannes-Schneider authored Jun 13, 2023
1 parent e64e1a8 commit 8ac2299
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ updates:
- dependency-name: "net.revelc.code.formatter:formatter-maven-plugin" # newer versions require Java > 8
- dependency-name: "net.revelc.code:impsort-maven-plugin" # newer versions require Java > 8
- dependency-name: "org.mockito:mockito-core" # newer versions require Java > 8
- dependency-name: "net.revelc.code:impsort-maven-plugin" # newer versions require Java > 8
4 changes: 2 additions & 2 deletions .github/workflows/code-ql-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: "CodeQL Scan"

on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]
branches: [ main ]

jobs:
CodeQL-Build:
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: dependabot merger

on:
pull_request:
branches: [ main ]

jobs:
review-pr:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' &&
github.event_name == 'pull_request' }}
permissions:
pull-requests: write
contents: write
steps:
- name: dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.5.1
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: comment major updates
if : ${{steps.metadata.outputs.update-type == 'version-update:semver-major' }}
run: |
gh pr comment $PR_URL --body "PR **not approved** because it includes a major update of a dependency"
gh pr edit $PR_URL --add-label "please review"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: approve and merge
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
run: |
gh pr review --approve "$PR_URL"
gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 comments on commit 8ac2299

Please sign in to comment.