-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaction.yml
More file actions
89 lines (76 loc) · 2.54 KB
/
action.yml
File metadata and controls
89 lines (76 loc) · 2.54 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
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
workspace:
description: "Workspace ID (uuid)"
required: false
runs:
using: "composite"
steps:
- name: Cache CLI binary
if: inputs.version != 'latest'
id: cache-cli
uses: actions/cache@v4
with:
path: "${{ runner.tool_cache }}/ctrlc/${{ inputs.version }}"
key: "ctrlplane-cli-${{ inputs.repo }}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}"
- name: Download binary
if: steps.cache-cli.outputs.cache-hit != 'true'
shell: bash
run: |
set -u # bail when referencing unset variables
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 -sfSL https://api.github.com/repos/${{ inputs.repo }}/releases/latest | jq -e -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 -sfSL "${DOWNLOAD_URL}" -o binary.tar.gz
tar xzf binary.tar.gz
chmod +x ctrlc
cache_dir="${{ runner.tool_cache }}/ctrlc/${{ inputs.version }}"
mkdir -p "${cache_dir}"
mv ctrlc "${cache_dir}"
- name: Add ctrlc to path
shell: bash
run: |
echo "${{ runner.tool_cache }}/ctrlc/${{ inputs.version }}" >> "${GITHUB_PATH}"
- 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 }}
- name: Set Ctrlplane Workspace
shell: bash
if: inputs.workspace != ''
run: |
ctrlc config set workspace ${{ inputs.workspace }}