ci: add gradle lockfile refresh for dependabot (#1989)
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
# For some reason, Dependabot refuses to refresh the lockfiles for
|
||||
# gradle, so this bumps the lockfile explicitly.
|
||||
name: Dependabot
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
paths:
|
||||
- "backend/build.gradle.kts"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: dependabot-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
refresh-lockfiles:
|
||||
name: Refresh Gradle Lockfiles
|
||||
runs-on: ubuntu-latest
|
||||
if: github.actor == 'dependabot[bot]'
|
||||
|
||||
steps:
|
||||
- name: Checkout PR branch
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
ref: ${{ github.head_ref }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install just
|
||||
uses: taiki-e/install-action@16b05812d776ae1dfaabc8277e421fb6d2506419 # v2.82.7
|
||||
with:
|
||||
tool: just
|
||||
|
||||
- name: Set Up JDK 25
|
||||
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5
|
||||
with:
|
||||
java-version: '25'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Restore Gradle Cache
|
||||
id: restore_gradle_cache
|
||||
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: gradle-${{ runner.os }}-${{ hashFiles('backend/**/*.gradle*', 'backend/settings.gradle*', 'backend/gradle.properties', 'backend/gradle/wrapper/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
gradle-${{ runner.os }}-
|
||||
|
||||
- name: Refresh lockfiles
|
||||
working-directory: backend/
|
||||
run: ./gradlew dependencies --write-locks
|
||||
|
||||
- name: Save Gradle Cache
|
||||
if: ${{ always() }}
|
||||
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ steps.restore_gradle_cache.outputs.cache-primary-key }}
|
||||
|
||||
- name: Commit and push
|
||||
env:
|
||||
GITHUB_TOKEN_GIT_URL: "https://actions:${{ github.token }}@github.com/${{ github.repository }}"
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
ORIGINAL_GIT_URL="$(git remote get-url origin)"
|
||||
|
||||
git add '**/gradle.lockfile'
|
||||
if git diff --cached --quiet; then
|
||||
echo "No lockfile changes"
|
||||
else
|
||||
git commit -m "chore(deps): update gradle lockfiles"
|
||||
|
||||
git remote set-url origin "$GITHUB_TOKEN_GIT_URL"
|
||||
git push origin
|
||||
git remote set-url origin "$ORIGINAL_GIT_URL"
|
||||
fi
|
||||
Reference in New Issue
Block a user