-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
61 lines (53 loc) · 1.66 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
name: Install Ctrlplane CLI
description: Installs the Ctrlplane CLI binary from a GitHub repository
inputs:
version:
description: "Version of the binary to install"
required: false
default: "latest"
repo:
description: "GitHub repository containing the binary (format: owner/repo)"
required: true
default: "ctrlplanedev/cli"
url:
description: "URL of the ctrlplane instance"
required: false
api_key:
description: "API key for the ctrlplane instance"
required: false
runs:
using: "composite"
steps:
- name: Download binary
shell: bash
run: |
OS=$(uname -s)
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
ARCH="x86_64"
elif [ "$ARCH" = "aarch64" ]; then
ARCH="arm64"
fi
BINARY_NAME="ctrlc_${OS}_${ARCH}"
echo "BINARY_NAME: $BINARY_NAME"
if [ "${{ inputs.version }}" = "latest" ]; then
VERSION=$(curl -s https://api.github.com/repos/${{ inputs.repo }}/releases/latest | jq -r .tag_name)
else
VERSION=${{ inputs.version }}
fi
DOWNLOAD_URL="https://github.com/${{ inputs.repo }}/releases/download/${VERSION}/$BINARY_NAME.tar.gz"
echo "DOWNLOAD_URL: $DOWNLOAD_URL"
curl -L $DOWNLOAD_URL -o binary.tar.gz
tar xzf binary.tar.gz
chmod +x ctrlc
sudo mv ctrlc /usr/local/bin/
- name: Set Ctrlplane URL
shell: bash
if: inputs.url != ''
run: |
ctrlc config set url ${{ inputs.url }}
- name: Set Ctrlplane API Key
shell: bash
if: inputs.api_key != ''
run: |
ctrlc config set api-key ${{ inputs.api_key }}