-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
197 lines (179 loc) · 6.63 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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: "Starship Devnet"
description: "Run mini cosmos ecosystem via devnet"
branding:
color: blue
icon: anchor
inputs:
config:
description: "Path to the config file"
required: true
cli-version:
description: "Version of @starship-ci/cli to use: default: 2.10.2"
required: false
default: "2.10.2"
kubeconfig:
description: "Kubeconfig file for remote cluster, if set, will be used instead of creating kind cluster"
required: false
default: ""
chart:
description: "Name of the help chart to use. Recommended: use default (default: starship/devnet)"
required: false
default: "starship/devnet"
repo:
description: "Helm repo to fetch the chart from (default: https://cosmology-tech.github.io/starship)"
required: false
default: "https://cosmology-tech.github.io/starship"
name:
description: "Helm chart release name for installing helm chart (default: starship-devnet)"
required: false
default: "starship-devnet"
namespace:
description: "Kubernetes namespace to deploy helm charts on (default: ci-{github.repository}-{github.workflow}-{github.ref} )"
required: false
default: ""
timeout:
description: "Timeout for helm install (default: 10m)"
required: false
default: "10m"
outputs:
namespace:
description: "Kubernetes namespace to which helm charts were deployed"
value: ${{ steps.set-namespace.outputs.namespace }}
name:
description: "Helm chart release name for installing helm chart"
value: ${{ inputs.name }}
runs:
using: composite
steps:
- name: Create yarn.lock and package.json file if not exists
if: inputs.cli-version != '0.0.0' # Skip if cli-version is 0.0.0, expected to be used for local testing
run: |
if [ ! -f $GITHUB_WORKSPACE/yarn.lock ]; then
echo 'Creating temporary yarn.lock file'
echo '' > $GITHUB_WORKSPACE/yarn.lock
fi
if [ ! -f $GITHUB_WORKSPACE/package.json ]; then
echo 'Creating temporary package.json file'
echo '{}' > $GITHUB_WORKSPACE/package.json
fi
shell: bash
- name: Setup Node.js
uses: actions/setup-node@v4
if: inputs.cli-version != '0.0.0' # Skip if cli-version is 0.0.0, expected to be used for local testing
with:
node-version: "20.x"
cache: "yarn"
- name: Setup helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: Setup kubectl
uses: azure/setup-kubectl@v3
with:
version: v1.28.0
- name: Setup kind cluster
if: ${{ inputs.kubeconfig == '' }}
uses: helm/[email protected]
with:
cluster_name: kind-starship
- name: Create kubeconfig file
if: ${{ inputs.kubeconfig != '' }}
run: |
mkdir -p ~/.kube
echo -e "${{ inputs.kubeconfig }}" > ~/.kube/config
shell: bash
- name: Set namespace
id: set-namespace
run: |
namespace="ci-${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}"
if [ -n "$INPUT_NAMESPACE" ]; then
namespace="$INPUT_NAMESPACE"
fi
namespace="${namespace// /-}"
namespace="${namespace//\//-}"
namespace=$(awk '{print tolower($0)}' <<< $namespace)
(( ${#namespace} > 62 )) && namespace="$(echo $namespace | cut -c1-59)$((RANDOM%1000))"
namespace=$(echo $namespace | cut -c1-60)
echo "Setting namespace to $namespace"
echo "namespace=$namespace" >> $GITHUB_OUTPUT
shell: bash
env:
INPUT_NAMESPACE: ${{ inputs.namespace }}
- name: Create namespace if nonexistent
run: |
kubectl create namespace ${{ steps.set-namespace.outputs.namespace }} || true
shell: bash
- name: Setup starshipjs client
if: inputs.cli-version != '0.0.0' # Skip if cli-version is 0.0.0, expected to be used for local testing
run: |
yarn global add @starship-ci/cli@${{ inputs.cli-version }}
shell: bash
- name: Verify starship cli
run: |
starship --version
shell: bash
- name: Setup starship helm repo
run: |
starship setup \
--config ${{ inputs.config }} \
--name ${{ inputs.name }} \
--namespace ${{ steps.set-namespace.outputs.namespace }} \
--chart ${{ inputs.chart }}
shell: bash
- name: Helm install
id: helm-install-1
continue-on-error: true
run: |
helm delete ${{ inputs.name }} --debug --namespace ${{ steps.set-namespace.outputs.namespace }} --wait || true
sleep 5
starship start \
--config ${{ inputs.config }} \
--name ${{ inputs.name }} \
--namespace ${{ steps.set-namespace.outputs.namespace }} \
--chart ${{ inputs.chart }} \
--timeout ${{ inputs.timeout }}
shell: bash
- name: Logs
if: always()
run: |
kubectl get pods -n $NAMESPACE
for i in `kubectl get po -n $NAMESPACE -o json | jq -r '.items[].metadata.name'`; do
echo "==================================================="
echo "Logs for $i"
kubectl describe pods $i -n $NAMESPACE
kubectl logs $i -n $NAMESPACE --all-containers --tail=800
echo "==================================================="
done
env:
VALUES_FILE: ${{ inputs.config }}
NAMESPACE: ${{ steps.set-namespace.outputs.namespace }}
shell: bash
- name: Helm install again
id: helm-install-2
if: steps.helm-install-1.outcome == 'failure'
continue-on-error: true
run: |
helm delete ${{ inputs.name }} --debug --namespace ${{ steps.set-namespace.outputs.namespace }} --wait || true
sleep 5
kubectl get pods --namespace ${{ steps.set-namespace.outputs.namespace }}
starship start \
--config ${{ inputs.config }} \
--name ${{ inputs.name }} \
--namespace ${{ steps.set-namespace.outputs.namespace }} \
--chart ${{ inputs.chart }} \
--timeout ${{ inputs.timeout }}
shell: bash
- name: Helm install again, 3rd time is the charm
id: helm-install-3
if: steps.helm-install-2.outcome == 'failure'
run: |
helm delete ${{ inputs.name }} --debug --namespace ${{ steps.set-namespace.outputs.namespace }} --wait || true
sleep 5
kubectl get pods --namespace ${{ steps.set-namespace.outputs.namespace }}
starship start \
--config ${{ inputs.config }} \
--name ${{ inputs.name }} \
--namespace ${{ steps.set-namespace.outputs.namespace }} \
--chart ${{ inputs.chart }} \
--timeout ${{ inputs.timeout }}
shell: bash