Skip to content

Commit 5fd9d0c

Browse files
authored
Merge pull request #11 from zarthross/cached
Install SBT on self-hosted gha runners V2
2 parents 646c82c + 7caf3b5 commit 5fd9d0c

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

action.yml

+28-12
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,52 @@ inputs:
77
default: 1.10.2
88
runs:
99
using: "composite"
10+
1011
steps:
1112
- name: Set up cache paths
1213
id: cache-paths
1314
shell: bash
1415
run: |
15-
echo "setupsbt_path=$HOME/work/_setupsbt" >> $GITHUB_OUTPUT
16+
echo "sbt_toolpath=$RUNNER_TOOL_CACHE/sbt/${{ inputs.sbt-runner-version }}" >> "$GITHUB_OUTPUT"
17+
echo "sbt_downloadpath=$RUNNER_TEMP/_sbt" >> "$GITHUB_OUTPUT"
18+
19+
- name: Check Tool Cache
20+
id: cache-tool-dir
21+
shell: bash
22+
run: |
23+
mkdir -p "${{ steps.cache-paths.outputs.sbt_toolpath }}"
24+
if [ -f "${{ steps.cache-paths.outputs.sbt_toolpath }}/sbt/bin/sbt" ]; then
25+
echo "cache-hit=true" >> "$GITHUB_OUTPUT"
26+
else
27+
echo "cache-hit=false" >> "$GITHUB_OUTPUT"
28+
fi
1629
1730
- name: Cache sbt distribution
1831
id: cache-dir
32+
if: steps.cache-tool-dir.outputs.cache-hit != 'true'
1933
uses: actions/cache@v4
2034
with:
21-
path: ${{ steps.cache-paths.outputs.setupsbt_path }}
22-
key: ${{ runner.os }}-sbt-${{ inputs.sbt-runner-version }}-1.1.1
35+
path: ${{ steps.cache-paths.outputs.sbt_toolpath }}
36+
key: ${{ runner.os }}-sbt-${{ inputs.sbt-runner-version }}-1.1.4
2337

24-
- name: "Install sbt"
38+
- name: "Download and Install sbt"
2539
shell: bash
26-
if: steps.cache-dir.outputs.cache-hit != 'true'
27-
run: |
28-
mkdir -p "${{ steps.cache-paths.outputs.setupsbt_path }}"
29-
curl -sL https://github.com/sbt/sbt/releases/download/v$SBT_RUNNER_VERSION/sbt-$SBT_RUNNER_VERSION.zip > "${{ steps.cache-paths.outputs.setupsbt_path }}/sbt-$SBT_RUNNER_VERSION.zip"
30-
pushd "${{ steps.cache-paths.outputs.setupsbt_path }}"
31-
unzip -o "sbt-$SBT_RUNNER_VERSION.zip"
32-
popd
3340
env:
3441
SBT_RUNNER_VERSION: ${{ inputs.sbt-runner-version }}
42+
if: steps.cache-tool-dir.outputs.cache-hit != 'true' && steps.cache-dir.outputs.cache-hit != 'true'
43+
run: |
44+
mkdir -p "${{ steps.cache-paths.outputs.sbt_downloadpath }}"
45+
curl -sL "https://github.com/sbt/sbt/releases/download/v$SBT_RUNNER_VERSION/sbt-$SBT_RUNNER_VERSION.zip" > \
46+
"${{ steps.cache-paths.outputs.sbt_downloadpath }}/sbt-$SBT_RUNNER_VERSION.zip"
47+
48+
pushd "${{ steps.cache-paths.outputs.sbt_downloadpath }}"
49+
unzip -o "sbt-${{ inputs.sbt-runner-version }}.zip" -d "${{ steps.cache-paths.outputs.sbt_toolpath }}"
50+
popd
3551
3652
- name: "Setup PATH"
3753
shell: bash
3854
run: |
39-
pushd "${{ steps.cache-paths.outputs.setupsbt_path }}"
55+
pushd "${{ steps.cache-paths.outputs.sbt_toolpath }}"
4056
ls sbt/bin/sbt
4157
echo "$PWD/sbt/bin" >> "$GITHUB_PATH"
4258
popd

0 commit comments

Comments
 (0)