-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
54 lines (52 loc) · 1.71 KB
/
action.yml
File metadata and controls
54 lines (52 loc) · 1.71 KB
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
name: 'Setup Sdkman'
author: 'Sergii Fesenko'
description: 'Manage dependencies with sdkman'
inputs:
deps:
required: true
default: ''
description: |
space separated list of dependencies with optional version:
dependency1[:version1] dependency2[:version2] ...
branding:
icon: 'download'
color: 'blue'
runs:
using: "composite"
steps:
- name: Prepare configuration
id: prepare
shell: bash
run: |
DEPS=$(tr -s [:blank:] \\n <<< "${{ inputs.deps }}" | sort | uniq | xargs)
DEPS_HASH=$(md5sum <<< $DEPS | cut -f1 -d' ')
# don't cache /.sdkman/ for self-hosted runners
if [ "${{ startsWith (runner.name, 'GitHub Actions') }}" == "true" ]; then
CACHE_PATH=~/.sdkman/
else
CACHE_PATH=/dev/null
fi
echo "deps=$DEPS" >> $GITHUB_OUTPUT
echo "hash=$DEPS_HASH" >> $GITHUB_OUTPUT
echo "path=$CACHE_PATH" >> $GITHUB_OUTPUT
- name: Restore sdkman cache
uses: actions/cache@v4
with:
path: ${{ steps.prepare.outputs.path }}
key: ${{ runner.os }}-${{ github.action }}-${{ steps.prepare.outputs.hash }}
- name: Setup sdkman
shell: bash
run: |
if [ ! -s ~/.sdkman/bin/sdkman-init.sh ]; then
curl -s "https://get.sdkman.io" | bash
. ~/.sdkman/bin/sdkman-init.sh
sed '/sdkman_auto_answer=/ s/=.*/=true/' -i ~/.sdkman/etc/config
else
. ~/.sdkman/bin/sdkman-init.sh
fi
for p in ${{ steps.prepare.outputs.deps }}; do
pkg=(`tr : ' ' <<< $p`)
sdk install ${pkg[0]} ${pkg[1]}
done
sdk flush || true
tr ':' \\n <<< "$PATH" | grep /.sdkman/ >> $GITHUB_PATH || true