This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
56 lines (53 loc) · 2.4 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
# action.yml
name: install-faas-cli
description: 'Install faas-cli and put it on your path'
branding:
icon: 'package'
color: 'blue'
# This is pinned to the last major release, we have to bump it for each action version.
inputs:
faas-cli-release:
description: 'faas-cli release version to use in the actions.'
required: false
default: '0.16.23'
runs:
using: "composite"
steps:
# We verify the version against a SHA **in the published action itself**, not in the GCS bucket.
- run: |
trap "popd" EXIT
mkdir -p $HOME/.faas-cli
pushd $HOME/.faas-cli
bootstrap_version='0.16.23'
expected_bootstrap_version_digest='1d369ee4037478825fec967367e3d14ee71ec95dae5fae7fcd61d6d6500b4179'
curl -L https://github.com/openfaas/faas-cli/releases/download/${bootstrap_version}/faas-cli -o faas-cli
shaBootstrap=$(sha256sum faas-cli | cut -d' ' -f1);
if [[ $shaBootstrap != ${expected_bootstrap_version_digest} ]]; then exit 1; fi
chmod +x faas-cli
# If the bootstrap and specified `faas-cli` releases are the same, we're done.
if [[ ${{ inputs.faas-cli-release }} == ${bootstrap_version} ]]; then exit 0; fi
semver='^([0-9]+\.){0,2}(\*|[0-9]+)$'
if [[ ${{ inputs.faas-cli-release }} =~ $semver ]]; then
echo "INFO: Custom faas-cli Version ${{ inputs.faas-cli-release }}"
else
echo "ERROR: Unable to validate faas-cli version: '${{ inputs.faas-cli-release }}'"
exit 1
fi
# Download custom faas-cli
curl -L https://github.com/openfaas/faas-cli/releases/download/${{ inputs.faas-cli-release }}/faas-cli -o faas-cli_${{ inputs.faas-cli-release }}
shaCustom=$(sha256sum faas-cli_${{ inputs.faas-cli-release }} | cut -d' ' -f1);
curl -L https://github.com/openfaas/faas-cli/releases/download/${{ inputs.faas-cli-release }}/faas-cli.sha256 -o faas-cli.sha256
expectedSha=$(cat faas-cli.sha256 | cut -d' ' -f1)
# same hash means it is the same release
if [[ $shaCustom == $expectedSha ]];
then
rm -f faas-cli faas-cli.sha256
mv faas-cli_${{ inputs.faas-cli-release }} faas-cli
chmod +x faas-cli
else
echo "ERROR: Wrong sha for faas-cli: '${{ inputs.faas-cli-release }}'"
exit 1
fi
shell: bash
- run: echo "$HOME/.faas-cli" >> $GITHUB_PATH
shell: bash