Skip to content

Commit

Permalink
ci: remove duplication to set up gradle cache
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospereira committed Dec 5, 2024
1 parent 2681d34 commit a6803f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
21 changes: 21 additions & 0 deletions .github/gradle-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Gradle Cache Action"
description: "Sets up Gradle Cache"

inputs:
key:
required: true
description: "The cache key"

runs:
using: composite
steps:
# Adapted from https://github.com/actions/cache/blob/v3/examples.md#java---gradle
- name: Cache Gradle local repository
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-${{ inputs.key }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-${{ inputs.key }}-
28 changes: 4 additions & 24 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,9 @@ jobs:
java-version: ${{ matrix.java_version }}
distribution: 'temurin'
cache: 'maven'

# Adapted from https://github.com/actions/cache/blob/v3/examples.md#java---gradle
- name: Cache local Gradle
id: gradleCache
uses: actions/cache@v4
- uses: ./.github/gradle-cache
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
key: "gradle"
- name: Make Maven Wrapper executable
if: contains(matrix.os, 'win') == false
run: chmod +x ./mvnw
Expand Down Expand Up @@ -113,19 +103,9 @@ jobs:
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'

# Adapted from https://github.com/actions/cache/blob/v3/examples.md#java---gradle
- name: Cache local Gradle
id: gradleCache
uses: actions/cache@v4
- uses: ./.github/gradle-cache
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-graalvm-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-graalvm-
key: "gradle-graalvm"
- name: Make Maven Wrapper executable
if: contains(matrix.os, 'win') == false
run: chmod +x ./mvnw
Expand Down

0 comments on commit a6803f0

Please sign in to comment.