-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
77 lines (72 loc) · 1.98 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Setup KubeDB
description: GitHub Action to install KubeDB during CI/CD.
branding:
icon: download
color: blue
inputs:
repo:
description: The KubeDB repo to use
default: clevyr/kubedb
token:
description: GitHub token
default: ${{ github.token }}
version:
description: The KubeDB version to install
default: latest
outputs:
version:
description: The KubeDB version that was installed
value: ${{ steps.install.outputs.version }}
runs:
using: composite
steps:
- id: install
name: Install KubeDB
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
GH_REPO: ${{ inputs.repo }}
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
if [[ "$VERSION" == latest ]]; then
VERSION=
fi
case "${{ runner.os }}" in
Linux)
OS=linux
FILENAME=kubedb
;;
macOS)
OS=darwin
FILENAME=kubedb
;;
Windows)
OS=windows
FILENAME=kubedb.exe
;;
esac
RELEASE="$(gh release view --json=name,assets $VERSION)"
VERSION="$(jq -r '.name' <<<"$RELEASE")"
echo "version=$VERSION" >>$GITHUB_OUTPUT
echo "Installing kubedb $VERSION..."
DEST="$RUNNER_TEMP/kubedb"
ASSET="$(jq -r --arg OS "$OS" \
'.assets[].name | select(ascii_downcase | test($OS + "_(amd64|x86_64).(tar.gz|zip)$"))' \
<<<"$RELEASE" \
)"
echo "Downloading $ASSET"
mkdir -p "$DEST"
cd "$DEST"
case "$ASSET" in
*.tar.gz)
gh release download "$VERSION" --pattern="$ASSET" --output=- | tar -xzf - "$FILENAME" ;;
*.zip)
gh release download "$VERSION" --pattern="$ASSET"
unzip -o "$ASSET" "$FILENAME"
rm "$ASSET"
;;
*)
echo Invalid file type; exit 1;;
esac
echo "$DEST" >>$GITHUB_PATH