-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
224 lines (193 loc) · 6.6 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
name: 'Runtime Manager Action'
description: 'Runtime Manager Action'
inputs:
CLIENT_ID:
description: Account client id
required: true
CLIENT_KEY:
description: Account client secret key
required: true
CLIENT_REALM:
description: Account client realm
required: true
WORKSPACE:
description: Workspace used to deploy
required: true
ENVIRONMENT:
description: Environment used to deploy
required: true
VERSION_TAG:
description: Deploy version tag
required: true
BRANCH:
description: Branch to perform checkout in Runtime
required: false
OPEN_API_PATH:
description: Path to API file to publish on StackSpot Catalog API
required: false
TF_STATE_BUCKET_NAME:
description: Bucket to save generated tfstate files
required: true
TF_STATE_REGION:
description: Region configuration for tfstate
required: true
IAC_BUCKET_NAME:
description: Bucket to save generated iac files
required: true
IAC_REGION:
description: Region configuration for iac
required: true
VERBOSE:
description: Verbose configuration
required: false
DYNAMIC_INPUTS:
description: --key1 value1 --key2 value2
required: false
default: ""
WORKDIR:
description: Path to the directory where the .stk is located.
required: false
default: "./"
BETA_CLI_ENVIRONMENT:
description: Environment in which cli will be executed. (default, stg, dev).
required: false
type: string
default: default
outputs:
tasks:
description: "RUN TASK LIST"
value: ${{ steps.deploy.outputs.tasks }}
run_id:
description: "RUN ID"
value: ${{ steps.deploy.outputs.run_id }}
runs:
using: "composite"
steps:
- name: Check Runner
run: echo 🤖 OS runner is $(uname)
shell: bash
- name: check envs
run: |
echo "${{ inputs.TF_STATE_BUCKET_NAME }}"
echo "${{ inputs.IAC_REGION }}"
shell: bash
- name: Get os version
run: |
cat /etc/os-release
uname -r
shell: bash
- name: Check glibc version
run: |
ldd --version
shell: bash
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4.7.1
with:
python-version: '3.10'
- name: Install python libraries
run: pip install requests ruamel-yaml==0.17.33
shell: bash
- name: Setup STK CLI
if: inputs.BETA_CLI_ENVIRONMENT == 'default'
uses: stack-spot/stk-cli-action@main
with:
client_id: ${{ inputs.CLIENT_ID }}
client_key: ${{ inputs.CLIENT_KEY }}
realm: ${{ inputs.CLIENT_REALM }}
- name: Setup STK CLI STG
if: inputs.BETA_CLI_ENVIRONMENT == 'stg'
uses: stack-spot/stk-cli-action@stg
with:
client_id: ${{ inputs.CLIENT_ID }}
client_key: ${{ inputs.CLIENT_KEY }}
realm: ${{ inputs.CLIENT_REALM }}
- name: Setup STK CLI DEV
if: inputs.BETA_CLI_ENVIRONMENT == 'dev'
uses: stack-spot/stk-cli-action@dev
with:
client_id: ${{ inputs.CLIENT_ID }}
client_key: ${{ inputs.CLIENT_KEY }}
realm: ${{ inputs.CLIENT_REALM }}
- name: Generate manifesto
working-directory: ${{ inputs.WORKDIR }}
env:
LANG: C.UTF-8
LANGUAGE: C.UTF-8
LC_ALL: C.UTF-8
PYTHONIOENCODING: utf-8
run: |
if [ "${{ inputs.BETA_CLI_ENVIRONMENT }}" == "default" ]; then
CLI="stk"
elif [ "${{ inputs.BETA_CLI_ENVIRONMENT }}" == "stg" ]; then
CLI="stk-stg"
elif [ "${{ inputs.BETA_CLI_ENVIRONMENT }}" == "dev" ]; then
CLI="stk-dev"
else
echo "Invalid environment: ${{ inputs.BETA_CLI_ENVIRONMENT }}"
exit 1
fi
$CLI use workspace ${{ inputs.WORKSPACE }}
FLAGS=$(echo "--env ${{ inputs.ENVIRONMENT }} --target ${{ github.action_path }} --version ${{ inputs.VERSION_TAG }}")
if [ ! -z "${{ inputs.BRANCH }}" ]; then
FLAGS=$(echo "$FLAGS --branch ${{ inputs.BRANCH }}")
fi
if [ ! -z "${{ inputs.OPEN_API_PATH }}" ]; then
FLAGS=$(echo "$FLAGS --open-api-path ${{ inputs.OPEN_API_PATH }}")
fi
if [ ! -z "${{ inputs.DYNAMIC_INPUTS }}" ]; then
FLAGS=$(echo "$FLAGS ${{ inputs.DYNAMIC_INPUTS }}")
fi
if [ ! -z "${{ inputs.VERBOSE }}" ]; then
echo "DEPLOY PLAN FLAGS = $FLAGS"
fi
$CLI deploy plan $FLAGS
shell: bash
- name: Define Domains
id: stackspot-url
run: |
if [ "${{ inputs.BETA_CLI_ENVIRONMENT }}" == "default" ]; then
STACKSPOT_IAM_URL="https://auth.stackspot.com"
STACKSPOT_RUNTIME_MANAGER_URL="https://runtime-manager.v1.stackspot.com"
elif [ "${{ inputs.BETA_CLI_ENVIRONMENT }}" == "stg" ]; then
STACKSPOT_IAM_URL="https://iam-auth-ssr.stg.stackspot.com"
STACKSPOT_RUNTIME_MANAGER_URL="https://runtime-manager.stg.stackspot.com"
elif [ "${{ inputs.BETA_CLI_ENVIRONMENT }}" == "dev" ]; then
STACKSPOT_IAM_URL="https://iam-auth-ssr.dev.stackspot.com"
STACKSPOT_RUNTIME_MANAGER_URL="https://runtime-manager.dev.stackspot.com"
else
echo "Invalid environment: ${{ inputs.BETA_CLI_ENVIRONMENT }}"
exit 1
fi
echo "iam=$STACKSPOT_IAM_URL" >> "$GITHUB_OUTPUT"
echo "runtime_manager=$STACKSPOT_RUNTIME_MANAGER_URL" >> "$GITHUB_OUTPUT"
shell: bash
- name: Start Self Hosted DEPLOY run with Runtime
id: deploy
working-directory: ${{ inputs.WORKDIR }}
env:
STACKSPOT_IAM_URL: ${{ steps.stackspot-url.outputs.iam }}
STACKSPOT_RUNTIME_MANAGER_URL: ${{ steps.stackspot-url.outputs.runtime_manager }}
ACTION_PATH: ${{ github.action_path }}
CLIENT_ID: ${{ inputs.CLIENT_ID }}
CLIENT_KEY: ${{ inputs.CLIENT_KEY }}
CLIENT_REALM: ${{ inputs.CLIENT_REALM }}
TF_STATE_BUCKET_NAME: ${{ inputs.TF_STATE_BUCKET_NAME }}
TF_STATE_REGION: ${{ inputs.TF_STATE_REGION }}
IAC_BUCKET_NAME: ${{ inputs.IAC_BUCKET_NAME }}
IAC_REGION: ${{ inputs.IAC_REGION }}
VERBOSE: ${{ inputs.VERBOSE }}
run: |
if [ ${{runner.os}} != 'Windows' ]; then
python3 ${{ github.action_path }}/runtime.py
elif [ ${{runner.os}} == 'Windows' ]; then
python ${{ github.action_path }}\runtime.py
else
echo "${{runner.os}} not supported"
exit 1
fi
shell: bash
branding:
icon: 'terminal'
color: 'gray-dark'