Skip to content

Commit e68724e

Browse files
committed
caching musl
1 parent d297cea commit e68724e

1 file changed

Lines changed: 35 additions & 4 deletions

File tree

.github/actions/setup_cached_java/action.yml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,21 @@ runs:
2020
- name: Install GitHub CLI
2121
shell: bash
2222
run: |
23-
sudo apt update
24-
sudo apt install -y gh
23+
if [[ ${{ inputs.arch }} =~ "-musl" ]]; then
24+
set -x
25+
apk update
26+
apk add curl git
27+
git config --global --add safe.directory /__w/java-profiler/java-profiler
28+
29+
GH_VERSION=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | grep '"tag_name":' | cut -d '"' -f 4 | sed 's/v//')
30+
curl -L -o gh.tar.gz "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz"
31+
tar -xzf gh.tar.gz
32+
mv gh_${GH_VERSION}_linux_amd64/bin/gh /usr/local/bin/
33+
rm -rf gh_${GH_VERSION}_linux_amd64 gh.tar.gz
34+
else
35+
sudo apt update
36+
sudo apt install -y gh
37+
fi
2538
- name: Infer Build JDK
2639
shell: bash
2740
id: infer_build_jdk
@@ -51,15 +64,15 @@ runs:
5164
restore-keys: |
5265
jdk${{ inputs.version }}-${{ inputs.arch }}--
5366
- name: Refresh JDK cache
54-
if: steps.cache_jdk.outputs.cache-hit != 'true' || steps.cache_build_jdk.outputs.cache-hit != 'true' || 'true' == 'true'
67+
if: steps.cache_jdk.outputs.cache-hit != 'true' || steps.cache_build_jdk.outputs.cache-hit != 'true'
5568
shell: bash
5669
env:
5770
GH_TOKEN: ${{ inputs.github_token }}
5871
run: |
5972
echo "JDK cache miss detected! Triggering refresh workflow..."
6073
gh workflow run cache_java.yml
6174
- name: Wait for JDK cache refresh
62-
if: steps.cache_jdk.outputs.cache-hit != 'true' || steps.cache_build_jdk.outputs.cache-hit != 'true' || 'true' == 'true'
75+
if: steps.cache_jdk.outputs.cache-hit != 'true' || steps.cache_build_jdk.outputs.cache-hit != 'true'
6376
shell: bash
6477
env:
6578
GH_TOKEN: ${{ inputs.github_token }}
@@ -68,6 +81,24 @@ runs:
6881
echo "Waiting for JDK cache refresh to complete..."
6982
sleep 10
7083
done
84+
- name: Cache Build JDK [${{ inputs.arch }}] (Retry)
85+
if: steps.cache_build_jdk.outputs.cache-hit != 'true'
86+
uses: actions/cache/restore@v4
87+
with:
88+
path: |
89+
jdks/${{ steps.infer_build_jdk.outputs.build_jdk }}
90+
key: ${{ steps.infer_build_jdk.outputs.build_jdk }}-${{ inputs.arch }}--${{ hashFiles('.github/workflows/cache_java.yml', '.github/scripts/java_setup.sh') }}
91+
restore-keys: |
92+
${{ steps.infer_build_jdk.outputs.build_jdk }}-${{ inputs.arch }}--
93+
- name: Cache JDK ${{ inputs.version }} [${{ inputs.arch }}] (Retry)
94+
if: steps.cache_jdk.outputs.cache-hit != 'true'
95+
uses: actions/cache/restore@v4
96+
with:
97+
path: |
98+
jdks/jdk${{ inputs.version }}
99+
key: jdk${{ inputs.version }}-${{ inputs.arch }}--${{ hashFiles('.github/workflows/cache_java.yml', '.github/scripts/java_setup.sh') }}
100+
restore-keys: |
101+
jdk${{ inputs.version }}-${{ inputs.arch }}--
71102
- name: Setup Environment
72103
shell: bash
73104
run: |

0 commit comments

Comments
 (0)