-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
233 lines (212 loc) · 6.54 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
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
image: node:10
stages:
- lint
- test
- build
- release
- publish
- deploy_dev
lint:
stage: lint
except:
- triggers
tags:
- docker
image: node:10
script:
- npm install
- npm run lint -- --no-fix
except:
- tags@linagora/lgs/smartsla/smartsla-frontend
### BEGIN OF TEMPLATES
.build-docker-tpl: &build-docker-tpl
image: docker-registry.linagora.com:5000/linshare-snapshots/linshare-dind:latest
tags:
- docker
services:
- name: docker-registry.linagora.com:5000/linshare-snapshots/linshare-dind:latest
alias: docker-dind
### END OF TEMPLATES
# build and optionaly test your image here.
build:
<<: *build-docker-tpl
stage: build
variables:
DOCKER_HOST: "tcp://docker-dind"
script:
- docker build . -t build:latest
except:
refs:
- master@linagora/lgs/smartsla/smartsla-frontend
- tags@linagora/lgs/smartsla/smartsla-frontend
- /^release-.*/@linagora/lgs/smartsla/smartsla-frontend
variables:
- $SKIP_BUILD_DOCKER
check_author:
image: docker-registry.linagora.com:5000/lgs-releases/gitlab-integrity-checks:latest
stage: lint
variables:
GIT_DEPTH: "1"
tags:
- ultralight
script:
- check_author.py check "$GITLAB_USER_EMAIL" "$GITLAB_USER_NAME" --no-accents
except:
refs:
- master@linagora/lgs/smartsla/smartsla-frontend
- tags@linagora/lgs/smartsla/smartsla-frontend
- /^release-.*/@linagora/lgs/smartsla/smartsla-frontend
test_unit:
stage: test
except:
- triggers
tags:
- docker
image: node:10
script:
- npm install
- npm run test:unit
except:
- tags@linagora/lgs/smartsla/smartsla-frontend
.test_e2e:
stage: test
except:
- triggers
tags:
- docker
environment:
name: production
image: cypress/base:10
script:
- npm install
- npm run test:e2e -- --headless
####### Build & publish branch base docker images (master branch, release maintaining branches, feature branches)
.docker-internal-registry: &docker-internal-registry
- guess-version.sh guess
- source version.env
- docker-tag-computing.sh ${VERSION} docker-tag-and-push.env
- source docker-tag-and-push.env
- docker login -u ${REGISTRY_USER} -p ${REGISTRY_TOKEN} docker-registry.linagora.com:5000
- docker build . -t localimage
- docker-tag-and-push.sh localimage ${DOCKER_IMAGE_PRIVATE}
- docker logout docker-registry.linagora.com:5000
.docker-public-registry: &docker-public-registry
- docker login -u ${HUB_DOCKER_USER} -p ${HUB_DOCKER_TOKEN}
- docker tag localimage ${DOCKER_IMAGE_PUBLIC}:${DOCKER_PUBLIC_TAG_NAME}
- docker push ${DOCKER_IMAGE_PUBLIC}:${DOCKER_PUBLIC_TAG_NAME}
- docker logout
variables: &docker-branches-variables
DOCKER_HOST: "tcp://docker-dind"
DOCKER_IMAGE_PRIVATE: "docker-registry.linagora.com:5000/smartsla-snapshots/smartsla-frontend"
DOCKER_IMAGE_PUBLIC: "smartsla/smartsla-frontend"
docker-master:
<<: *build-docker-tpl
stage: release
variables:
<<: *docker-branches-variables
DOCKER_PUBLIC_TAG_NAME: "branch-master"
script:
- *docker-internal-registry
- *docker-public-registry
only:
- master@linagora/lgs/smartsla/smartsla-frontend
except:
variables:
- $SKIP_BUILD_DOCKER
docker-snapshot:
<<: *build-docker-tpl
stage: release
variables:
<<: *docker-branches-variables
script:
- *docker-internal-registry
- export DOCKER_PUBLIC_TAG_NAME=branch-${DOCKER_TAG}
- *docker-public-registry
only:
- /^release-.*/@linagora/lgs/smartsla/smartsla-frontend
except:
variables:
- $SKIP_BUILD_DOCKER
docker-feature:
<<: *build-docker-tpl
stage: build
variables:
<<: *docker-branches-variables
script:
- export DOCKER_PUBLIC_TAG_NAME=${CI_COMMIT_REF_NAME}
- docker login -u ${REGISTRY_USER} -p ${REGISTRY_TOKEN} docker-registry.linagora.com:5000
- docker build . -t localimage
- docker tag localimage ${DOCKER_IMAGE_PRIVATE}:${DOCKER_PUBLIC_TAG_NAME}
- docker push ${DOCKER_IMAGE_PRIVATE}:${DOCKER_PUBLIC_TAG_NAME}
- docker logout docker-registry.linagora.com:5000
- *docker-public-registry
only:
- /^feature-.*/@linagora/lgs/smartsla/smartsla-frontend
except:
variables:
- $SKIP_BUILD_DOCKER
####### Build & publish release
docker-release:
<<: *build-docker-tpl
stage: release
variables:
DOCKER_HOST: "tcp://docker-dind"
DOCKER_IMAGE_PRIVATE: "docker-registry.linagora.com:5000/smartsla-releases/smartsla-frontend"
DOCKER_IMAGE_PUBLIC: "smartsla/smartsla-frontend"
script:
- docker-tag-computing.sh ${CI_COMMIT_TAG} docker-tag-and-push.env
- docker login -u ${REGISTRY_USER_RELEASE} -p ${REGISTRY_TOKEN_RELEASE} docker-registry.linagora.com:5000
- docker login -u ${HUB_DOCKER_USER} -p ${HUB_DOCKER_TOKEN}
- docker build . -t localimage
- docker-tag-and-push.sh localimage ${DOCKER_IMAGE_PRIVATE} ${DOCKER_IMAGE_PUBLIC}
- docker logout
only:
- tags@linagora/lgs/smartsla/smartsla-frontend
except:
variables:
- $SKIP_BUILD_DOCKER
# push the latest docker tag from the current docker tag, cf last job.
mark-as-latest:
<<: *build-docker-tpl
stage: publish
variables:
GIT_STRATEGY: none
DOCKER_HOST: "tcp://docker-dind"
DOCKER_IMAGE_PRIVATE: "docker-registry.linagora.com:5000/smartsla-releases/smartsla-frontend"
DOCKER_IMAGE_PUBLIC: "smartsla/smartsla-frontend"
script:
- docker login -u ${REGISTRY_USER_RELEASE} -p ${REGISTRY_TOKEN_RELEASE} docker-registry.linagora.com:5000
- docker login -u ${HUB_DOCKER_USER} -p ${HUB_DOCKER_TOKEN}
- docker-tag-computing.sh ${CI_COMMIT_TAG} docker-tags.env
- source docker-tags.env
- docker pull ${DOCKER_IMAGE_PRIVATE}:${DOCKER_TAG}
- export DOCKER_TAGS=latest
- docker-tag-and-push.sh ${DOCKER_IMAGE_PRIVATE}:${DOCKER_TAG} ${DOCKER_IMAGE_PRIVATE} ${DOCKER_IMAGE_PUBLIC}
- docker logout
when: manual
only:
- tags@linagora/lgs/smartsla/smartsla-frontend
deploy_dev:
stage: deploy_dev
except:
- triggers
tags:
- dev.open-paas.org
- deployment
environment:
name: dev
url: https://dev.open-paas.org
only:
- master@linagora/lgs/smartsla/smartsla-frontend
script:
- cd /srv/${CI_PROJECT_NAME}
- nvm use
- git fetch --all
- git checkout ${CI_COMMIT_SHA}
- npm install
- npm update
- git checkout -- .
- BASE_URL=/smartsla/ npm run build
- rm -fr /srv/vue-apps/${CI_PROJECT_NAME}/*
- cp -fr /srv/${CI_PROJECT_NAME}/dist/* /srv/vue-apps/${CI_PROJECT_NAME}/
- cp -fr /srv/${CI_PROJECT_NAME}/production/openpaas.js /srv/vue-apps/${CI_PROJECT_NAME}/env/openpaas.js