-
Notifications
You must be signed in to change notification settings - Fork 0
274 lines (230 loc) · 9.58 KB
/
publish-cloud-dashboard.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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
name: Build-Push dashboard
on:
push:
branches:
- main
- staging
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: update managed-dashboard with secrets values - staging
if: github.ref == 'refs/heads/staging'
env:
NEXT_PUBLIC_WS_API_URL: "${{ secrets.STAGING_NEXT_PUBLIC_WS_API_URL }}"
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: "${{ secrets.STAGING_NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}"
API_URL: "${{ secrets.STAGING_API_URL }}"
run: |
envsubst < ./.env.production | tee .env.production
- name: update managed-dashboard with secrets values - production
if: github.ref == 'refs/heads/main'
env:
NEXT_PUBLIC_WS_API_URL: "${{ secrets.PROD_NEXT_PUBLIC_WS_API_URL }}"
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: "${{ secrets.PROD_NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}"
API_URL: "${{ secrets.PROD_API_URL }}"
run: |
envsubst < ./.env.production | tee .env.production
# - name: Install pnpm
# uses: pnpm/action-setup@v2
# with:
# version: 7
# - name: Cypress run
# uses: cypress-io/github-action@v5
# with:
# install-command: yarn --frozen-lockfile --silent
# # using the action parameter command causes multiple other parameters to be ignored
# #command: yarn cypress:open
# component: true
# browser: chrome
# build: yarn build
# start: yarn start
# wait-on: "http://localhost:3000"
# # wait for 2 minutes for the server to respond
# wait-on-timeout: 120
# # Cancel the run after 2 failed tests # run with cloud only
# # auto-cancel-after-failures: 2
# - name: Cypress Artifacts
# # after the test run completes store videos and any screenshots
# # store generated videos and screenshots as CI artifacts.
# uses: actions/upload-artifact@v3
# # add the line below to store screenshots only on failures
# # if: failure()
# with:
# name: cypress-screenshots
# path: cypress/screenshots
# if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`
# - uses: actions/upload-artifact@v3
# with:
# name: cypress-videos
# path: cypress/videos
# if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`
- name: Generate Docker metadata for staging
id: meta-staging
uses: docker/metadata-action@v3
if: github.ref == 'refs/heads/staging'
with:
images: |
docker.io/kotalco/cloud-dashboard
tags: |
type=ref,event=tag
type=sha,prefix=,suffix=,format=short
- name: Generate Docker metadata for production
id: meta-production
uses: docker/metadata-action@v3
if: github.ref == 'refs/heads/main'
with:
images: |
docker.io/kotalco/cloud-dashboard
tags: |
type=ref,event=tag
type=sha,prefix=,suffix=,format=short
flavor: |
latest=true
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: kotalco
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push staging
uses: docker/build-push-action@v3
if: github.ref == 'refs/heads/staging'
with:
context: .
push: true
tags: ${{ steps.meta-staging.outputs.tags }}
labels: ${{ steps.meta-staging.outputs.labels }}
- name: Build and push production
uses: docker/build-push-action@v3
if: github.ref == 'refs/heads/main'
with:
context: .
push: true
tags: ${{ steps.meta-production.outputs.tags }}
labels: ${{ steps.meta-production.outputs.labels }}
deploy_managed-dashboard_k8s-managed-staging:
runs-on: ubuntu-latest
needs: [build]
if: ${{ (github.event_name == 'push') && (github.ref == 'refs/heads/staging') }}
steps:
- uses: actions/checkout@v3
- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
- name: Kustomize and validate k8s-manifests
uses: yokawasa/action-setup-kube-tools@v0.9.2
with:
setup-tools: |
kubeconform
kustomize
kubeconform: '0.5.0'
kustomize: '4.5.7'
- run: |
kustomize build k8s-manifests/environments/staging | kubeconform -verbose
kustomize build k8s-manifests/environments/staging > ./staging-managed-dashboard.yaml
# environment values are passed in build time, not override in runtime -- replace image tag only in deployment.yaml file
- name: update managed-dashboard with secrets values - staging
env:
NEXT_PUBLIC_WS_API_URL: "${{ secrets.PROD_NEXT_PUBLIC_WS_API_URL }}"
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: "${{ secrets.PROD_NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}"
API_URL: "${{ secrets.PROD_API_URL }}"
run: |
envsubst < ./staging-managed-dashboard.yaml | tee staging-managed-dashboard.yaml
- name: K8s-set-context to DO managed-staging cluster
uses: azure/k8s-set-context@v1
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBECONFIG_DO_MANAGED_STAGING }}
- name: Deploy to the DO managed-staging cluster
uses: azure/k8s-deploy@v1
with:
namespace: kotal
manifests: |
staging-managed-dashboard.yaml
# deploy_managed-dashboard_k8s-managed-production:
# runs-on: ubuntu-latest
# needs: [build]
# if: ${{ (github.event_name == 'push') && (github.ref == 'refs/heads/main') }}
# steps:
# - uses: actions/checkout@v3
# - name: Add SHORT_SHA env property with commit short sha
# run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
# - name: Kustomize and validate k8s-manifests
# uses: yokawasa/action-setup-kube-tools@v0.9.2
# with:
# setup-tools: |
# kubeconform
# kustomize
# kubeconform: '0.5.0'
# kustomize: '4.5.7'
# - run: |
# kustomize build k8s-manifests/environments/production | kubeconform -verbose
# kustomize build k8s-manifests/environments/production > ./prod-managed-dashboard.yaml
# - name: update managed-dashboard with secrets values - production
# env:
# NEXT_PUBLIC_WS_API_URL: "${{ secrets.PROD_NEXT_PUBLIC_WS_API_URL }}"
# NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: "${{ secrets.PROD_NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY }}"
# API_URL: "${{ secrets.PROD_API_URL }}"
# run: |
# envsubst < ./prod-managed-dashboard.yaml | tee prod-managed-dashboard.yaml
# - name: K8s-set-context to DO managed-production cluster
# uses: azure/k8s-set-context@v1
# with:
# method: kubeconfig
# kubeconfig: ${{ secrets.KUBECONFIG_DO_MANAGED_PRODUCTION }}
# - name: Deploy to the DO managed-production cluster
# uses: azure/k8s-deploy@v1
# with:
# namespace: kotal
# manifests: |
# prod-managed-dashboard.yaml
testing_dashboard_on_Cloud-Providers:
runs-on: ubuntu-latest
needs: [build]
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
- name: Checkout kotal-helm-chart Repo
uses: actions/checkout@v3
with:
repository: kotalco/kotal-helm-chart
path: kotal-helm-chart
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: Add helm dependencies repositories
run: |
for dir in $(ls -d kotal-helm-chart/charts/*/); do
helm dependency list $dir 2> /dev/null | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done
done
helm dependency update kotal-helm-chart/charts/kotal
- name: K8s-set-context to DO testing cluster
uses: azure/k8s-set-context@v1
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBECONFIG_DO_TESTING }}
- name: Testing and Update Kotal-Helm-Chart in DO with kotal dashboard new image [kotal.cloud]
run: |
helm upgrade kotal kotal-helm-chart/charts/kotal --install --wait --namespace=kotal --create-namespace --set "dashboard.tag=${SHORT_SHA}" --set "staging=true" --set=app.name=kotal --reuse-values --atomic
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_EKS_ADMIN }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_EKS_ADMIN }}
aws-region: eu-central-1
- name: K8s-set-context to EKS testing cluster
uses: azure/k8s-set-context@v1
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBECONFIG_EKS_TESTING }}
- name: Testing and Update Kotal-Helm-Chart in EKS with kotal dashboard new image
run: |
helm upgrade kotal kotal-helm-chart/charts/kotal --install --wait --namespace=kotal --create-namespace --set-string "dashboard.tag=${SHORT_SHA}" --set "staging=true" --set=app.name=kotal --reuse-values --atomic