Skip to content

Commit 84e5762

Browse files
committed
Allow setup action to just restore maven cache
Useful for jobs which can make use of cached maven repo but are not downloading whole repo by themselves so the maven repo as left by the job should not be cached.
1 parent 7be1ac4 commit 84e5762

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

.github/actions/setup/action.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
description: "Java version to setup"
66
default: 17
77
cache:
8-
description: "Cache Maven repo"
8+
description: "Cache Maven repo (true/false/restore)"
99
default: true
1010
download_dependencies:
1111
description: "Download all Maven dependencies so Maven can work in offline mode"
@@ -38,7 +38,7 @@ runs:
3838
with:
3939
distribution: 'temurin' # use same JDK distro as in Trino docker images
4040
java-version: ${{ inputs.java-version }}
41-
- name: Cache local Maven repo
41+
- name: Cache and Restore local Maven repo
4242
id: cache
4343
if: ${{ format('{0}', inputs.cache) == 'true' }}
4444
uses: actions/cache@v3
@@ -47,6 +47,15 @@ runs:
4747
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
4848
restore-keys: |
4949
${{ runner.os }}-maven-
50+
- name: Restore local Maven repo
51+
id: cache_restore
52+
if: ${{ format('{0}', inputs.cache) == 'restore' }}
53+
uses: actions/cache/restore@v3
54+
with:
55+
path: ~/.m2/repository
56+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
57+
restore-keys: |
58+
${{ runner.os }}-maven-
5059
- name: Fetch any missing dependencies
5160
shell: bash
5261
if: ${{ format('{0}', inputs.download_dependencies) == 'true' }}

0 commit comments

Comments
 (0)