generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 206
/
action.yaml
52 lines (47 loc) · 1.75 KB
/
action.yaml
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
name: Setup kwok
description: This action sets up kwok/kwokctl for use in your workflow
inputs:
command:
required: true
description: Command to install
kwok-version:
required: false
description: Specific version of command to install, defaults to latest release
repository:
required: false
description: Repository is kwok's repository, will use release from this repository, defaults same as uses in this step
default: "kubernetes-sigs/kwok"
runs:
using: composite
steps:
- name: Install ${{ inputs.command }}
shell: bash
env:
KWOK_REPO: ${{ inputs.repository }}
KWOK_VERSION: ${{ inputs.kwok-version }}
run: |
if [[ -f /usr/local/bin/${{ inputs.command }} ]]; then
echo "Found ${{ inputs.command }} in /usr/local/bin, skipping installation"
exit 0
fi
if [[ -z "${KWOK_VERSION}" ]]; then
echo "Fetching latest version..."
KWOK_VERSION="$(curl "https://api.github.com/repos/${KWOK_REPO}/releases/latest" | jq -r '.tag_name')"
if [[ -z "${KWOK_VERSION}" ]]; then
echo "Failed to fetch latest version"
exit 1
fi
if [[ "${KWOK_VERSION}" == "null" ]]; then
echo "Failed to fetch latest version"
exit 1
fi
echo "Latest version is ${KWOK_VERSION}"
fi
echo "Installing ${{ inputs.command }} ${KWOK_VERSION}..."
wget -O ${{ inputs.command }} "https://github.com/${KWOK_REPO}/releases/download/${KWOK_VERSION}/${{ inputs.command }}-$(go env GOOS)-$(go env GOARCH)"
chmod +x ${{ inputs.command }}
sudo mv ${{ inputs.command }} /usr/local/bin/
if ! ${{ inputs.command }} --version; then
echo "Failed to run ${{ inputs.command }} --version"
exit 1
fi