-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
91 lines (83 loc) · 3.16 KB
/
action.yml
File metadata and controls
91 lines (83 loc) · 3.16 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
name: setup-hcloud
author: "@vbem"
description: 🌼 Setup Huawei Cloud KooCLI - `hcloud` CLI
branding: {icon: terminal, color: gray-dark}
inputs:
agree-privacy:
description: Whether to agree privacy statement when installing KooCLI, default to true
required: false
default: "true"
check-version:
description: Whether to check KooCLI version after installation, default to true
required: false
default: "true"
base-url:
description: Base URL for KooCLI binary releases
required: false
default: https://cn-north-4-hdn-koocli.obs.cn-north-4.myhuaweicloud.com/cli/latest/
outputs:
url:
description: "URL of official KooCLI package used for installation"
value: ${{ steps.unix.outputs.url }}
path:
description: "Path to KooCLI binary"
value: ${{ steps.unix.outputs.path }}
version:
description: "The checked KooCLI version"
value: ${{ steps.unix.outputs.version }}
runs:
using: composite
steps:
- if: runner.os == 'macOS' || runner.os == 'Linux'
id: unix
shell: bash
run: |
# `setup-hcloud` action implementation details
# Group stdin to stderr with title
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines
# $1: group title
# stdin: logs
# stderr: grouped logs
# $?: 0 if successful and non-zero otherwise
function kit::wf::group {
echo "::group::$1" >&2
echo "$(< /dev/stdin)" >&2
echo '::endgroup::' >&2
}
declare app_os='' app_arch='' app_url=''
case "${{ runner.os }}" in
'macOS') app_os='mac' ;;
'Linux') app_os='linux' ;;
*) echo "Unsupported Runner OS: '${{ runner.os }}'"; exit 1 ;;
esac
case "${{ runner.arch }}" in
'X64') app_arch='amd64' ;;
'ARM64') app_arch='arm64' ;;
*) echo "Unsupported Runner Architecture: '${{ runner.arch }}'"; exit 1 ;;
esac
app_url="${{ inputs.base-url }}huaweicloud-cli-${app_os}-${app_arch}.tar.gz"
echo "url=${app_url}" >> "$GITHUB_OUTPUT"
{
curl -fsSL "$app_url" | sudo tar -xzC /usr/local/bin hcloud
sudo chmod a+rx /usr/local/bin/hcloud
which hcloud
echo "path=$(which hcloud)" >> "$GITHUB_OUTPUT"
} |& kit::wf::group "🌼 Install Huawei Cloud KooCLI"
if [[ '${{ inputs.agree-privacy }}' == 'true' ]]; then
hcloud configure set --cli-agree-privacy-statement=true \
|& kit::wf::group "⚙️ Agree Privacy Statement for KooCLI"
if [[ '${{ inputs.check-version }}' == 'true' ]]; then
hcloud version |& kit::wf::group "🔍 Check KooCLI Version"
echo "version=$(hcloud version | head -n1)" >> "$GITHUB_OUTPUT"
fi
fi
- if: runner.os == 'Windows'
id: windows
shell: pwsh
run: |
curl -fsSL -O "${{ inputs.base-url }}huaweicloud-cli-windows-amd64.zip"
Expand-Archive -Path ./huaweicloud-cli-windows-amd64.zip -DestinationPath ./out
$env:PATH = "$env:PATH;$pwd/out"
which hcloud
hcloud version