Skip to content

Commit cfa30ae

Browse files
committed
Use cache for mc binary
Signed-off-by: Kostis Papazafeiropoulos <papazof@gmail.com>
1 parent 63df409 commit cfa30ae

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

action.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,40 @@ inputs:
2626
runs:
2727
using: composite
2828
steps:
29+
- name: Check if mc is installed
30+
id: check-mc
31+
run: |
32+
if [[ -n "$(which mc)" ]]; then
33+
echo "exists=true" >> "$GITHUB_OUTPUT"
34+
else
35+
echo "exists=false" >> "$GITHUB_OUTPUT"
36+
fi
37+
shell: bash
38+
39+
- name: Download latest mc SHA256
40+
id: mc-sha
41+
if: ${{ steps.check-mc.outputs.exists == 'false' }}
42+
run: |
43+
sha=$(wget -qO- \
44+
https://dl.min.io/client/mc/release/linux-amd64/mc.sha256sum \
45+
| awk '{print $1}')
46+
echo "sha256=$sha" >> "$GITHUB_OUTPUT"
47+
shell: bash
48+
49+
- name: Cache mc binary
50+
id: cache-mc
51+
if: ${{ steps.check-mc.outputs.exists == 'false' }}
52+
uses: actions/cache@v4
53+
with:
54+
path: /usr/local/bin/mc
55+
key: mc-${{ steps.mc-sha.outputs.sha256 }}
56+
2957
- name: Setup mc
3058
working-directory: /usr/local/bin
59+
if: >-
60+
${{ steps.check-mc.outputs.exists == 'false'
61+
&& steps.cache-mc.outputs.cache-hit != 'true' }}
3162
run: |
32-
[ -n "$(which mc)" ] && exit 0
3363
arch=$(dpkg --print-architecture | sed 's/armhf/arm/g')
3464
sudo wget --progres=dot:binary \
3565
"https://dl.min.io/client/mc/release/linux-${arch}/mc"

0 commit comments

Comments
 (0)