-
Notifications
You must be signed in to change notification settings - Fork 8
503 lines (451 loc) · 17.5 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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# 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
- "feat/**"
pull_request:
workflow_dispatch:
env:
CI: true
PNPM_CACHE_FOLDER: .pnpm-store
# set default for ACR variables
ACR_ENDPOINT: ${{ secrets.ACR_ENDPOINT || 'dummy' }}
ACR_USERNAME: ${{ secrets.ACR_USERNAME || '' }}
ACR_PASSWORD: ${{ secrets.ACR_PASSWORD || '' }}
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 }}
undpcomponents: ${{ steps.changes.outputs.undpcomponents }}
staticapi: ${{ steps.changes.outputs.staticapi }}
pgtileserv: ${{ steps.changes.outputs.pgtileserv }}
datapipeline: ${{ steps.changes.outputs.datapipeline }}
cogserver-dev: ${{ steps.changes.outputs.cogserver-dev }}
cogserver: ${{ steps.changes.outputs.cogserver }}
stacpipeline: ${{ steps.changes.outputs.stacpipeline }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
base: ${{ github.ref }}
filters: |
geohub:
- 'sites/geohub/**'
- 'packages/**'
- '.github/workflows/ci.yml'
- '.github/workflows/release.yml'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- ./docker/Dockerfile.production
docs:
- 'documentation/**'
- '.github/workflows/ci.yml'
undpdesign:
- 'packages/svelte-undp-design/**'
- 'package.json'
- 'pnpm-lock.yaml'
- '.github/workflows/ci.yml'
undpcomponents:
- 'packages/svelte-undp-components/**'
- 'package.json'
- 'pnpm-lock.yaml'
- '.github/workflows/ci.yml'
staticapi:
- 'sites/static-image-api/**'
- '.github/workflows/ci.yml'
pgtileserv:
- 'backends/k8s/pgtileserv/**'
- '.github/workflows/ci.yml'
datapipeline:
- 'backends/k8s/data-pipeline/yaml/ingest-environment.yaml'
- '.github/workflows/bump-pipeline.yml'
- '.github/workflows/ci.yml'
cogserver-dev:
- 'backends/k8s/cogserver/yaml/cogserver-dev-deployment.yaml'
- '.github/workflows/bump-cogserver.yml'
- '.github/workflows/ci.yml'
cogserver:
- 'backends/k8s/cogserver/yaml/cogserver-deployment.yaml'
- '.github/workflows/bump-cogserver.yml'
- '.github/workflows/ci.yml'
stacpipeline:
- 'backends/k8s/stac-pipeline/yaml/deployment.yaml'
- '.github/workflows/ci.yml'
lint_build:
name: lint, build and test for GeoHub
needs: changes
if: ${{ needs.changes.outputs.geohub == 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22]
steps:
- name: checkout code repository
uses: actions/checkout@v4
- uses: pnpm/[email protected]
- 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
build-docker:
name: Build & Deploy Docker Image
needs: changes
if: ${{ github.repository == 'undp-data/geohub' && needs.changes.outputs.geohub == 'true' }}
runs-on: ubuntu-latest
env:
IMAGE_NAME: undp-data/geohub
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log into ACR
uses: docker/login-action@v3
if: ${{ env.ACR_USERNAME != '' && env.ACR_PASSWORD != ''}}
with:
registry: ${{ env.ACR_ENDPOINT }}
username: ${{ env.ACR_USERNAME }}
password: ${{ env.ACR_PASSWORD }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.ACR_ENDPOINT }}/${{ env.IMAGE_NAME }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile.production
# push docker image only for main branch and branch name starts with `develop`
# also push docker image for branches named like `feat/`
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/feat/') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
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
strategy:
matrix:
node-version: [22]
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]
- 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: build storybook
run: |
pnpm --filter="./packages/undp-bulma" build
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-undp-components:
name: Build and deploy svelte UNDP components storybook
needs: changes
if: ${{ needs.changes.outputs.undpcomponents == 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22]
environment:
name: Svelte UNDP Components
url: https://svelte-undp-components.undpgeohub.org/
steps:
- name: checkout code repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/[email protected]
- 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: build storybook
run: |
pnpm --filter="./packages/undp-bulma" build
pnpm --filter="./packages/svelte-undp-design" build
pnpm --filter="./packages/svelte-undp-components" build
pnpm --filter="./packages/svelte-undp-components" 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-components/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
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: |
apt-get update && apt-get upgrade -y && apt-get install -y libcairo2
pip install --upgrade pip
pip install -r requirements.txt
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Copy and generate markdown file for slides
working-directory: ./documentation
run: python generate-slides.py
- name: Build documentation for production
if: ${{ (github.ref == 'refs/heads/main') }}
working-directory: ./documentation
env:
SITE_URL: https://docs.undpgeohub.org
EDIT_URL: https://github.com/undp-data/geohub/blob/${{ steps.extract_branch.outputs.branch }}/documentation/docs
run: mkdocs build
- name: Build documentation for dev
if: ${{ (github.ref != 'refs/heads/main') }}
working-directory: ./documentation
env:
SITE_URL: https://docs-dev.undpgeohub.org
EDIT_URL: https://github.com/undp-data/geohub/blob/${{ steps.extract_branch.outputs.branch }}/documentation/docs
run: mkdocs build
- name: deploy userguide to Blob container Prod
if: ${{ (github.ref == 'refs/heads/main') }}
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"
- name: deploy userguide to Blob container Dev
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_DEV }}
# WARNING: this will overwrite existing blobs in your blob storage
sync: "true"
build_static_api_acr:
name: Build and deploy Static Image API to ACR
needs: changes
if: ${{ github.repository == 'undp-data/geohub' && needs.changes.outputs.staticapi == 'true' }}
runs-on: ubuntu-24.04
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
if: ${{ env.ACR_USERNAME != '' && env.ACR_PASSWORD != ''}}
with:
registry: ${{ env.ACR_ENDPOINT }}
username: ${{ env.ACR_USERNAME }}
password: ${{ env.ACR_PASSWORD }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.ACR_ENDPOINT }}/${{ vars.IMAGE_NAME }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./sites/static-image-api
push: ${{ github.ref == 'refs/heads/develop'}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build_static_api_ghcr:
name: Build and deploy Static Image API to GitHub Package
needs: changes
if: ${{ needs.changes.outputs.staticapi == 'true' }}
runs-on: ubuntu-24.04
environment:
name: Static Image API
url: https://staticimage.undpgeohub.org
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/${{ vars.IMAGE_NAME }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log into GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
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-24.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/[email protected]
with:
args: apply -f backends/k8s/pgtileserv/yaml/pgtileserv-deployment.yaml
- name: Delete Secrets for pgtileserv
uses: actions-hub/[email protected]
with:
args: delete secret pgtileserv-secrets --ignore-not-found -n ${{ env.PGTILESERV_NAMESPACE }}
- name: Create Secrets for pgtileserv
uses: actions-hub/[email protected]
with:
args: create secret generic pgtileserv-secrets --from-literal=DATABASE_URL=${{ secrets.DATABASE_URL }} -n ${{ env.PGTILESERV_NAMESPACE }}
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/[email protected]
with:
args: delete secret ingest-secrets --ignore-not-found -n ${{ env.DEPLOYMENT_NAMESPACE }}
- name: Create Secrets
uses: actions-hub/[email protected]
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/[email protected]
env:
SERVICE_BUS_CONNECTION_STRING: ${{ secrets.SERVICE_BUS_CONNECTION_STRING }}
with:
args: apply -f backends/k8s/data-pipeline/yaml/ingest-environment.yaml
k8s_cogserver_dev_deploy:
name: Deploy cogserver-dev to Kubernetes
needs: changes
if: ${{ github.ref == 'refs/heads/develop' && needs.changes.outputs.cogserver-dev == 'true' }}
runs-on: ubuntu-24.04
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
environment:
name: K8S cogserver-dev
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy cogserver-dev to kubernetes
uses: actions-hub/[email protected]
with:
args: apply -f backends/k8s/cogserver/yaml/cogserver-dev-deployment.yaml
k8s_cogserver_deploy:
name: Deploy cogserver to Kubernetes
needs: changes
if: ${{ github.ref == 'refs/heads/main' && needs.changes.outputs.cogserver == 'true' }}
runs-on: ubuntu-24.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/[email protected]
with:
args: apply -f backends/k8s/cogserver/yaml/cogserver-deployment.yaml
k8s_stacpipeline_deploy:
name: Deploy geo-undpstac-pipeline to Kubernetes
needs: changes
if: ${{ github.ref == 'refs/heads/develop' && needs.changes.outputs.stacpipeline == 'true' }}
runs-on: ubuntu-latest
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
DEPLOYMENT_NAMESPACE: stac
AZURE_SERVICE_BUS_QUEUE_NAME: undp-stac-pipeline
environment:
name: K8S stac-pipeline
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Delete Secrets
uses: actions-hub/[email protected]
with:
args: delete secret stac-secrets --ignore-not-found -n ${{ env.DEPLOYMENT_NAMESPACE }}
- name: Create Secrets
uses: actions-hub/[email protected]
with:
args: create secret generic stac-secrets --from-literal=AZURE_STORAGE_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} --from-literal=AZURE_SERVICE_BUS_CONNECTION_STRING=${{ secrets.AZURE_SERVICE_BUS_CONNECTION_STRING }} --from-literal=AZURE_SERVICE_BUS_QUEUE_NAME=${{ env.AZURE_SERVICE_BUS_QUEUE_NAME }} -n ${{ env.DEPLOYMENT_NAMESPACE }}
- name: Deploy ingest to kubernetes
uses: actions-hub/[email protected]
env:
AZURE_SERVICE_BUS_CONNECTION_STRING: ${{ secrets.AZURE_SERVICE_BUS_CONNECTION_STRING }}
with:
args: apply -f backends/k8s/stac-pipeline/yaml/deployment.yaml