-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
211 lines (193 loc) · 6.21 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
default:
image: gitlab.virtualcitysystems.de:5050/vcsuite/devops/gitlabrunner/node:20-bullseye
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PROJECT_PATH_SLUG/$CI_COMMIT_REF_SLUG
stages:
- build
- test
- bundle
- version
- deploy
- deployCluster
- publish
- docs
.template: &job_definition
only:
- /^(feature-.*|hotfix-.*|main|release-.*)$/
tags:
- linux-2.0
build:
<<: *job_definition
script:
- npm set registry 'http://npmregistry:4873'
- npm ci
before_script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_RUNNER_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan gitlab.virtualcitysystems.de >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git config user.name "Gitlab Runner"
- git config user.email "[email protected]"
stage: build
.after_build_template: &after_build_definition
<<: *job_definition
variables:
GIT_STRATEGY: none
lint:
<<: *after_build_definition
stage: test
script:
- npm run lint
type-check:
<<: *after_build_definition
stage: test
script:
- npm run build-types
test:
<<: *after_build_definition
stage: test
script:
- npm run coverage:gitlab
coverage: '/^Statements\s*:\s*([^%]+)/'
artifacts:
reports:
junit: test-report.xml
audit:
<<: *after_build_definition
stage: test
script:
- npm audit --production --audit-level=low
bundle:
<<: *after_build_definition
stage: bundle
before_script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_RUNNER_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan gitlab.virtualcitysystems.de >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git config user.name "Gitlab Runner"
- git config user.email "[email protected]"
script:
- npm set registry 'http://npmregistry:4873'
- cd plugins
- npm i --omit peer --no-package-lock --force
- cd ..
- npm run build
- npm run build-preview
- npm run story:build
version:
<<: *after_build_definition
stage: version
only:
variables:
- $PUBLISH
refs:
- /^(main|release-v.*)$/
script:
- LEVEL=$([ $CI_COMMIT_REF_NAME == "main" ] && echo "prerelease" || echo "patch")
- npm version $LEVEL -m "%s [skip-ci]"
- TAG=`git describe --abbrev=0`
- git push git@gitlab:vcsuite/npm/vcmap/ui.git $TAG
- git push git@gitlab:vcsuite/npm/vcmap/ui.git HEAD:$CI_COMMIT_REF_NAME
before_script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_RUNNER_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan gitlab >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git config user.name "Gitlab Runner"
- git config user.email "[email protected]"
deployStaging:
<<: *after_build_definition
stage: deploy
environment:
name: staging/$CI_COMMIT_REF_SLUG
url: http://$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG.stagingcluster.intern.virtualcitysystems.de
on_stop: stopEnvironment
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
script:
- mv .histoire/dist dist/story
- /kaniko/executor --context dist/ --dockerfile build/staging/Dockerfile --destination $CI_REGISTRY_IMAGE/staging:$CI_COMMIT_REF_SLUG
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
stopEnvironment:
stage: deploy
variables:
GIT_STRATEGY: none
image:
name: bitnami/kubectl:latest
entrypoint: ['']
tags:
- linux-2.0
script:
- echo "Stop environment staging/$CI_COMMIT_REF_NAME"
- echo "Delete namespace on k9s $CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG"
- kubectl config use-context vcsuite/cluster-management:agent
- kubectl delete namespace $CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG
when: manual
environment:
name: staging/$CI_COMMIT_REF_SLUG
action: stop
deployStagingCluster:
stage: deployCluster
inherit:
variables: false
variables:
STAGE_BRANCH: $CI_COMMIT_REF_SLUG
STAGE_PROJECT_NAME: $CI_PROJECT_PATH_SLUG
STAGE_REGISTRY_IMAGE: $CI_REGISTRY_IMAGE
STAGE_NAMESPACE: $CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG
trigger:
project: vcsuite/devops/manifests
branch: main
deployNew:
<<: *after_build_definition
stage: publish
only:
variables:
- $DEPLOY
script:
- npm i -D @vcsuite/publishtox --registry http://npmregistry:4873
- echo "{\"modules\":[\"config/www.config.json\"]}" > ./dist/app.config.json
- node_modules/.bin/publishToX sftp --prefix /map/virtualcitymap.de/dev hostingsftp.virtualcitypublisher.de --cores 4 -s ./dist -d .
publish:
<<: *after_build_definition
stage: publish
only:
refs:
- /^(main|release-v.*)$/
variables:
- $PUBLISH
script:
- npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
- NPM_TAG=$([ $CI_COMMIT_REF_NAME == "main" ] && echo "dev" || echo "latest")
- npm publish --registry https://registry.npmjs.org --access public --tag $NPM_TAG
- VERSION=$(node -pe "require('./package.json').version")
- npm pack
- npm run bundle
- tar -tf vcmap-ui-*.tgz | sed s/package/./ | zip -@ vcmap-ui.zip
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file vcmap-ui.zip "${CI_API_V4_URL}/projects/317/packages/generic/VCMapUI/${VERSION}/vcmap-ui-${VERSION}.zip"'
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file dist/vcmap-bundle.tar.gz "${CI_API_V4_URL}/projects/317/packages/generic/VCMapUI/${VERSION}/vcmap-bundle-${VERSION}.tar.gz"'
deployDocs:
<<: *after_build_definition
stage: docs
only:
variables:
- $PUBLISH
refs:
- /^(main|release-v.*)$/
script:
- VERSION=$(node -pe "const version = require('./package.json').version; /\d*\.\d*/.exec(version)[0]")
- HISTOIRE_DEPLOYMENT="/ui/${VERSION}/story/"
- npm run story:build
- npm i -D @vcsuite/publishtox --registry http://npmregistry:4873
- echo "Uploading documentation to /lib/ui/${VERSION}/story"
- node_modules/.bin/publishToX sftp --prefix /map/virtualcitymap.de/lib/ui/ hostingsftp.virtualcitypublisher.de --cores 4 -s ./.histoire/dist -d "${VERSION}/story/"