/
action.yml
65 lines (58 loc) · 2.19 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: 'Incremental Gradle build cache prepare'
description: 'Prepare to save incremental Gradle build cache'
inputs:
cache-read-only:
description: 'Gradle cache read only'
default: 'true'
java-version:
description: 'Java version'
default: '17'
job-id:
description: 'Job name to prefer'
default: 'nessie-ci'
job-instance:
description: 'Job instance to prefer'
default: 'ci'
runs:
using: "composite"
steps:
- name: Prep env
shell: bash
run: |
echo "GRADLE_BUILD_ACTION_CACHE_KEY_ENVIRONMENT=java-${{ inputs.java-version }}" >> ${GITHUB_ENV}
echo "GRADLE_BUILD_ACTION_CACHE_KEY_JOB=${{ inputs.job-id }}" >> ${GITHUB_ENV}
if [[ -n "${{ inputs.no-daemon }}" ]] ; then
echo "G_DAEMON_FLAG=--no-daemon" >> ${GITHUB_ENV}
fi
if [[ -n "${{ inputs.job-instance }}" ]] ; then
echo "GRADLE_BUILD_ACTION_CACHE_KEY_JOB_INSTANCE=${{ inputs.job-instance }}" >> ${GITHUB_ENV}
fi
- name: Gradle / Setup
uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3
with:
cache-read-only: ${{ inputs.cache-read-only }}
- name: Gradle / Init
shell: bash
run: ./gradlew -h
- name: Download existing workflow artifacts
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4
# Just in case, don't know the exact inner workings of Gradle's build cache and whether
# the download-action complains about duplicate files.
continue-on-error: true
with:
path: ~/downloaded-artifacts/
- name: Extract caches
shell: bash
run: |
echo "::group::Gradle build cache / add incremental updates"
mkdir -p ~/.gradle/caches/
if [[ -d ~/downloaded-artifacts/ ]] ; then
find ~/downloaded-artifacts/ -type f -name "ci-gradle-caches-*-${{ inputs.java-version }}.tar" | while read arch ; do
echo "Adding archive content from $arch ..."
(cd ~/.gradle/caches/ ; tar xf $arch)
done
else
echo "No previous build cache artifacts downloaded."
fi
date +%s > ~/caches-prepared-at-epoch
echo "::endgroup::"