This repository has been archived by the owner on Feb 20, 2022. It is now read-only.
/
.gitlab-ci.yml
155 lines (138 loc) · 3.01 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
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
variables:
NODE_VERSION: "12"
HELM_VERSION: "2.14.2"
stages:
- setup
- test
- build
- deploy
- cleanup
.setup:
stage: setup
image: node:$NODE_VERSION
script:
- npm install
artifacts:
paths:
- "*/node_modules"
expire_in: 1 hour
setup:api:
extends: .setup
before_script:
- cd api/
variables:
SUPPRESS_SUPPORT: "1"
setup:web:
extends: .setup
before_script:
- cd web/
.lint:
stage: test
image: node:$NODE_VERSION
script:
- npm run lint
lint:api:
extends: .lint
before_script:
- cd api/
dependencies:
- setup:api
lint:web:
extends: .lint
before_script:
- cd web/
dependencies:
- setup:web
.test:
stage: test
image: node:$NODE_VERSION
script:
- npm run test
test:api:
extends: .test
before_script:
- cd api/
dependencies:
- setup:api
test:web:
extends: .test
before_script:
- cd web/
dependencies:
- setup:web
.build:
stage: build
image: docker:stable
variables:
DOCKER_DRIVER: overlay2
services:
- docker:dind
before_script:
- echo "$GCP_API_KEY" | base64 -d | docker login --username _json_key --password-stdin https://eu.gcr.io
only:
- master
build:api:
extends: .build
script:
- cd api/
- docker build -t eu.gcr.io/${GCP_PROJECT_ID}/bistrotime-api:${CI_COMMIT_SHA} .
- docker push eu.gcr.io/${GCP_PROJECT_ID}/bistrotime-api:${CI_COMMIT_SHA}
dependencies:
- setup:api
build:web:
extends: .build
script:
- cd web/
- docker build
--build-arg ALGOLIA_PLACES_APP_ID
--build-arg ALGOLIA_PLACES_APP_KEY
--build-arg BISTROTIME_API_URL
--build-arg MAPBOX_TOKEN
--tag eu.gcr.io/${GCP_PROJECT_ID}/bistrotime-web:${CI_COMMIT_SHA} .
- docker push eu.gcr.io/${GCP_PROJECT_ID}/bistrotime-web:${CI_COMMIT_SHA}
dependencies:
- setup:web
.deploy:
stage: deploy
image:
name: gcr.io/kubernetes-helm/tiller:v${HELM_VERSION}
entrypoint: ["/bin/sh", "-c"]
dependencies: []
before_script:
- mkdir ~/.kube
- echo "$HELM_KUBECONFIG" | base64 -d > ~/.kube/config
- /helm init --client-only
- /helm version
only:
- master
deploy:api:
extends: .deploy
script:
- /helm upgrade
--install bistrotime-api charts/bistrotime-api
--namespace bistrotime
--set image.tag=${CI_COMMIT_SHA}
--set tokens.yelp=${YELP_TOKEN}
--set tokens.navitia=${NAVITIA_TOKEN}
--wait
deploy:web:
extends: .deploy
script:
- /helm upgrade
--install bistrotime-web charts/bistrotime-web
--namespace bistrotime
--set image.tag=${CI_COMMIT_SHA}
--wait
cleanup:
stage: cleanup
image: google/cloud-sdk:alpine
dependencies: []
before_script:
- echo "$GCP_API_KEY" | base64 -d > gcp-credentials.json
- gcloud auth activate-service-account --key-file=gcp-credentials.json
script:
- ./bin/gcr-cleanup.sh eu.gcr.io/${GCP_PROJECT_ID}/bistrotime-web 3
- ./bin/gcr-cleanup.sh eu.gcr.io/${GCP_PROJECT_ID}/bistrotime-api 3
when: always
only:
- master