-
Notifications
You must be signed in to change notification settings - Fork 8
398 lines (351 loc) · 12.3 KB
/
ci.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: CIs
on:
push:
branches:
- main
- develop
pull_request:
workflow_dispatch:
env:
CI: true
PNPM_CACHE_FOLDER: .pnpm-store
jobs:
changes:
name: checking file changes
runs-on: ubuntu-latest
outputs:
geohub: ${{ steps.changes.outputs.geohub }}
docs: ${{ steps.changes.outputs.docs }}
undpdesign: ${{ steps.changes.outputs.undpdesign }}
staticapi: ${{ steps.changes.outputs.staticapi }}
pgtileserv: ${{ steps.changes.outputs.pgtileserv }}
titiler: ${{ steps.changes.outputs.titiler }}
datapipeline: ${{ steps.changes.outputs.datapipeline }}
cogserver: ${{ steps.changes.outputs.cogserver }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
geohub:
- 'sites/geohub/**'
- 'packages/**'
- '.github/workflows/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- ./docker/Dockerfile.production
docs:
- 'documentation/**'
- '.github/workflows/**'
undpdesign:
- 'packages/svelte-undp-design/**'
- 'package.json'
- 'pnpm-lock.yaml'
- '.github/workflows/**'
staticapi:
- 'sites/static-image-api/**'
- '.github/workflows/**'
pgtileserv:
- 'backends/k8s/pgtileserv/**'
- '.github/workflows/**'
titiler:
- 'backends/k8s/titiler/**'
- '.github/workflows/**'
datapipeline:
- 'backends/k8s/data-pipeline/**'
- '.github/workflows/**'
cogserver:
- 'backends/k8s/cogserver/cogserver-deployment.yaml'
- '.github/workflows/bump-cogserver.yml'
- '.github/workflows/ci.yml'
lint_build:
name: lint, build and test for GeoHub
needs: changes
if: ${{ github.ref == 'refs/heads/main' || needs.changes.outputs.geohub == 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
steps:
- name: checkout code repository
uses: actions/checkout@v4
- uses: pnpm/[email protected]
with:
version: 8.6.1
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: install dependencies
run: pnpm install --frozen-lockfile
- name: Run Prettier
run: pnpm format
- name: Run lint
run: pnpm lint
- name: build
run: pnpm build
- name: Run unit tests
run: pnpm test
- name: Copy package.json / lock files to build folder
working-directory: ./sites/geohub
run: ./build-nodemodules.sh
- name: Archive artifact for deployment
run: zip release.zip ./sites/geohub/build/* -r
- name: Upload build outputs
uses: actions/upload-artifact@v4
with:
name: geohub-build-output
path: release.zip
deploy_to_develop:
name: Build and deploy Node.js app to Development
if: ${{ github.ref == 'refs/heads/develop'}}
needs: lint_build
runs-on: ubuntu-latest
environment:
name: Development
url: https://dev.undpgeohub.org
steps:
- name: checkout code repository
uses: actions/checkout@v4
- name: download build files from artifact
uses: actions/download-artifact@v4
with:
name: geohub-build-output
- name: unzip artifact for deployment
run: unzip release.zip
- name: "Deploy to Azure Web App for undpgeohub-dev"
id: deploy-to-webapp-dev
uses: azure/webapps-deploy@v3
with:
app-name: "undpgeohub-dev"
slot-name: "Production"
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE }}
package: ./sites/geohub/build
deploy_to_production:
name: Build and deploy Node.js app to Production
needs: lint_build
if: ${{ github.ref == 'refs/heads/main'}}
runs-on: ubuntu-latest
environment:
name: Production
url: https://geohub.data.undp.org
steps:
- name: checkout code repository
uses: actions/checkout@v4
- name: download build files from artifact
uses: actions/download-artifact@v4
with:
name: geohub-build-output
- name: unzip artifact for deployment
run: unzip release.zip
- name: "Deploy to Azure for undpgeohub"
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: "undpgeohub"
slot-name: "Production"
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE }}
package: ./sites/geohub/build
build-docker:
name: Build Docker Image
needs: changes
if: ${{ needs.changes.outputs.geohub == 'true' }}
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: undp-data/geohub
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: |
IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$(date +%s) ./docker/docker-build-prod.sh
build-and-deploy-undp-design:
name: Build and deploy svelte UNDP design storybook
needs: changes
if: ${{ needs.changes.outputs.undpdesign == 'true' }}
runs-on: ubuntu-latest
environment:
name: Svelte UNDP Design
url: https://svelte-undp-design.undpgeohub.org/
steps:
- name: checkout code repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/[email protected]
with:
version: 8.6.1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: pnpm
- name: install dependencies
run: pnpm install --frozen-lockfile
- name: build storybook
run: |
pnpm --filter="./packages/svelte-undp-design" build
pnpm --filter="./packages/svelte-undp-design" build-storybook
- name: deploy storybook to Blob container
if: ${{ (github.ref == 'refs/heads/develop') }}
uses: bacongobbler/azure-blob-storage-upload@main
with:
source_dir: packages/svelte-undp-design/storybook-static
container_name: $web
connection_string: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING_STORYBOOK }}
# WARNING: this will overwrite existing blobs in your blob storage
sync: "true"
build-and-deploy-userguide:
name: Build and deploy GeoHub userguide
needs: changes
if: ${{ needs.changes.outputs.docs == 'true' }}
runs-on: ubuntu-latest
environment:
name: GeoHub UserGuide
url: https://docs.undpgeohub.org/
steps:
- name: checkout code repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
- name: Install dependecies
working-directory: ./documentation
run: |
pip install pipenv
pipenv install --system
- name: Build documentation
working-directory: ./documentation
run: mkdocs build
- name: deploy userguide to Blob container
if: ${{ (github.ref == 'refs/heads/develop') }}
uses: bacongobbler/azure-blob-storage-upload@main
with:
source_dir: documentation/site
container_name: $web
connection_string: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING_USERGUIDE }}
# WARNING: this will overwrite existing blobs in your blob storage
sync: "true"
build_static_api:
name: Build and deploy Static Image API
needs: changes
if: ${{ needs.changes.outputs.staticapi == 'true' }}
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [18]
env:
IMAGE_NAME: geohub-static-image-api
environment:
name: Static Image API
url: https://staticimage.undpgeohub.org
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log into ACR
uses: docker/login-action@v3
with:
registry: ${{ secrets.ACR_ENDPOINT }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.ACR_ENDPOINT }}/${{ env.IMAGE_NAME }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./sites/static-image-api
push: ${{ github.ref == 'refs/heads/develop'}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
k8s_pgtileserv_deploy:
name: Deploy pg_tileserv to Kubernetes
needs: changes
if: ${{ github.ref == 'refs/heads/develop' && needs.changes.outputs.pgtileserv == 'true' }}
runs-on: ubuntu-22.04
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
PGTILESERV_NAMESPACE: pgtileserv
environment:
name: K8S pgtileserv
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy pgtileserv to kubernetes
uses: actions-hub/kubectl@master
with:
args: apply -f backends/k8s/pgtileserv/yaml/pgtileserv-deployment.yaml
- name: Delete Secrets for pgtileserv
uses: actions-hub/kubectl@master
with:
args: delete secret pgtileserv-secrets --ignore-not-found -n ${{ env.PGTILESERV_NAMESPACE }}
- name: Create Secrets for pgtileserv
uses: actions-hub/kubectl@master
with:
args: create secret generic pgtileserv-secrets --from-literal=DATABASE_URL=${{ secrets.DATABASE_URL }} -n ${{ env.PGTILESERV_NAMESPACE }}
k8s_titiler_deploy:
name: Deploy titiler to Kubernetes
needs: changes
if: ${{ github.ref == 'refs/heads/develop' && needs.changes.outputs.titiler == 'true' }}
runs-on: ubuntu-22.04
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
environment:
name: K8S titiler
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy titiler to kubernetes
uses: actions-hub/kubectl@master
with:
args: apply -f backends/k8s/titiler/yaml/titiler-deployment.yaml
k8s_datapipeline_deploy:
name: Deploy geohub-data-pipeline to Kubernetes
needs: changes
if: ${{ github.ref == 'refs/heads/develop' && needs.changes.outputs.datapipeline == 'true' }}
runs-on: ubuntu-latest
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
DEPLOYMENT_NAMESPACE: data
environment:
name: K8S data-pipeline
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Delete Secrets
uses: actions-hub/kubectl@master
with:
args: delete secret ingest-secrets --ignore-not-found -n ${{ env.DEPLOYMENT_NAMESPACE }}
- name: Create Secrets
uses: actions-hub/kubectl@master
with:
args: create secret generic ingest-secrets --from-literal=AZURE_STORAGE_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} --from-literal=SERVICE_BUS_CONNECTION_STRING=${{ secrets.SERVICE_BUS_CONNECTION_STRING }} --from-literal=AZURE_WEBPUBSUB_CONNECTION_STRING=${{ secrets.AZURE_WEBPUBSUB_CONNECTION_STRING }} -n ${{ env.DEPLOYMENT_NAMESPACE }}
- name: Deploy ingest to kubernetes
uses: actions-hub/kubectl@master
env:
SERVICE_BUS_CONNECTION_STRING: ${{ secrets.SERVICE_BUS_CONNECTION_STRING }}
with:
args: apply -f backends/k8s/data-pipeline/yaml/ingest-environment.yaml
k8s_cogserver_deploy:
name: Deploy cogserver to Kubernetes
needs: changes
if: ${{ github.ref == 'refs/heads/develop' && needs.changes.outputs.cogserver == 'true' }}
runs-on: ubuntu-22.04
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
environment:
name: K8S cogserver
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy cogserver to kubernetes
uses: actions-hub/kubectl@master
with:
args: apply -f backends/k8s/cogserver/yaml/cogserver-deployment.yaml