Skip to content

Commit

Permalink
PI-2401 Enable auto-merge for minor Dependabot PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-bcl committed Aug 5, 2024
1 parent 01b3d52 commit caac3de
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
* @ministryofjustice/probation-integration
settings.gradle.kts
.github/actions
14 changes: 13 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
groups:
minor:
update-types:
- "minor"
- "patch"
patterns:
- "*"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
minor:
update-types:
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Automated management of Dependabot PRs
name: Dependabot
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: ${{ github.token }}

- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}

- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}

- name: Auto-approve minor or patch versions
run: gh pr review --approve "$PR_URL"
if: steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch'
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ steps.app-token.outputs.token }}
59 changes: 59 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Gradle
on:
workflow_dispatch:
schedule:
- cron: "30 5 * * MON-FRI" # Every weekday at 05:30 UTC
push:
paths:
- gradlew
- gradlew.bat
- gradle/**
- .github/workflows/gradle.yml

jobs:
validate-wrapper:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v3

update-wrapper:
runs-on: ubuntu-latest
if: github.ref_name == 'main'
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}

- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
token: ${{ steps.app-token.outputs.token }}

- uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- uses: gradle-update/update-gradle-wrapper-action@0407394b9d173dfc9cf5695f9f560fef6d61a5fe # v1
with:
labels: dependencies
repo-token: ${{ steps.app-token.outputs.token }}

- name: Reset commit author # workaround for https://github.com/gradle-update/update-gradle-wrapper-action/issues/124
continue-on-error: true
run: |
if [ "$(git branch --show-current)" != main ]; then
git reset --soft "HEAD~$(find . -type f -name gradlew | wc -l)"
fi
- name: Commit and push
uses: dsanders11/github-app-commit-action@48d2ff8c1a855eb15d16afa97ae12616456d7cbc # v1.4.0
with:
fail-on-no-changes: false
force: true
message: Bump Gradle Wrapper to the latest version
token: ${{ steps.app-token.outputs.token }}

0 comments on commit caac3de

Please sign in to comment.