-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
94 lines (80 loc) · 2.2 KB
/
.gitlab-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
image: docker:latest
# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
services:
- docker:dind
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
paths:
- node_modules/
stages:
- pre-build
- build
- deploy
#- review
#- dast
#- staging
#- canary
#- production
#- performance
#- cleanup
pre-build:
stage: pre-build
image: nikolaik/python-nodejs:python3.7-nodejs12
script:
- yarn install
- yarn run lint
- yarn build
- node ./create-gke-manifest.js
artifacts:
paths:
- api/dist
- media/dist
- website/.next
- kubernetesConfigs
only:
- main
build:
stage: build
dependencies:
- pre-build
script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker build --pull -t "$CI_REGISTRY_IMAGE/api:$CI_COMMIT_SHORT_SHA" ./api
- docker push "$CI_REGISTRY_IMAGE/api:$CI_COMMIT_SHORT_SHA"
- docker build --pull -t "$CI_REGISTRY_IMAGE/editor:$CI_COMMIT_SHORT_SHA" ./editor
- docker push "$CI_REGISTRY_IMAGE/editor:$CI_COMMIT_SHORT_SHA"
- docker build --pull -t "$CI_REGISTRY_IMAGE/media:$CI_COMMIT_SHORT_SHA" ./media
- docker push "$CI_REGISTRY_IMAGE/media:$CI_COMMIT_SHORT_SHA"
- docker build --pull -t "$CI_REGISTRY_IMAGE/website:$CI_COMMIT_SHORT_SHA" ./website
- docker push "$CI_REGISTRY_IMAGE/website:$CI_COMMIT_SHORT_SHA"
only:
- main
.delpoy: &deploy_template
stage: deploy
image: google/cloud-sdk:latest
dependencies:
- pre-build
script:
- echo $GCLOUD_SERVICE_KEY | base64 -d > gcloud-service-key.json
- gcloud auth activate-service-account --key-file gcloud-service-key.json
- kubectl apply -f ./kubernetesConfigs --kubeconfig $KUBECONFIG
deploy_staging:
<<: *deploy_template
environment:
name: staging
url: https://new.tsri.dev
only:
- main
#deploy_prod:
# <<: *deploy_template
# environment:
# name: production
# url: https://tsri.ch
# when: manual
# variables:
# TARGET: "production"
# only:
# - tags