-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
156 lines (147 loc) · 3.63 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
stages:
- test
- build
- deploy
image: node:20-alpine
variables:
MR_DEPLOY_ENVIRONMENT:
value: "dev-review"
options:
- "dev-review"
- "feature-review"
description: "Choose the environment to deploy the MR"
cache:
# Cache modules in between jobs: https://docs.gitlab.com/ee/ci/caching/#cache-nodejs-dependencies
- key: $CI_COMMIT_REF_SLUG
paths:
- .npm/
# We do not cache node_modules for Angular projects until they are used between several jobs
# - angular/.npm
test:
tags:
# - saas-linux-medium-amd64
- sncf-runner
image: zenika/alpine-chrome:with-puppeteer
stage: test
script:
- npm ci --cache .npm --prefer-offline
- npm test
build:
tags:
- sncf-runner
stage: build
artifacts:
expire_in: 4 days
paths:
- storybook-static/
- loader/
- dist/
- angular/dist/wcs-angular/
- angular/dist/wcs-formly/
- react/dist/
script:
# Build wcs core
- npm ci --cache .npm --prefer-offline --ignore-scripts puppeteer
- npm run build
# Build angular packages
- cd angular/
- npm ci --cache .npm --prefer-offline
- npm run build:wcs-angular
- npm run build:wcs-formly
- cd ..
# Build react packages
- cd react/
- npm ci --cache .npm --prefer-offline
- npm run build
- cd ..
# Old deploy job for Gitlab Pages, now replaced by deploy-azure (we deploy a redirect page to Gitlab Pages)
pages:
tags:
- gitlab-org
stage: deploy
dependencies:
- build
only:
- develop
- master
artifacts:
expire_in: 4 days
paths:
- public
script:
- mkdir -p public/develop/
- mkdir -p public/master/
- cp -r doc/gitlab-pages-redirect-root/* public/
- cp -r doc/gitlab-pages-redirect-root/* public/develop/
- cp -r doc/gitlab-pages-redirect-root/* public/master/
deploy-azure:
image: node:20
stage: deploy
tags:
- sncf-runner
rules:
- if: $CI_COMMIT_BRANCH == "master"
variables:
DEPLOY_ENV_NAME: "production"
- if: $CI_COMMIT_BRANCH == "develop"
variables:
DEPLOY_ENV_NAME: "develop"
variables:
DIST_PATH: '$CI_PROJECT_DIR/storybook-static'
script:
- npm install -g @azure/static-web-apps-cli
- swa deploy --app-location ./ --output-location $DIST_PATH --verbose=silly --deployment-token $DEPLOYMENT_TOKEN --env $DEPLOY_ENV_NAME
# PUBLISH PACKAGES FOR TAGS
publish-wcs-core:
tags:
- sncf-runner
stage: deploy
only:
- tags
dependencies:
- build
script:
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc && npm publish
publish-wcs-angular:
tags:
- sncf-runner
stage: deploy
only:
- tags
dependencies:
- build
script:
- cd angular/dist/wcs-angular/ && echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc && npm publish
publish-wcs-formly:
tags:
- sncf-runner
stage: deploy
only:
- tags
dependencies:
- build
script:
- cd angular/dist/wcs-formly/ && echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc && npm publish
publish-wcs-react:
tags:
- sncf-runner
stage: deploy
only:
- tags
dependencies:
- build
script:
- cd react/ && echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc && npm publish
# TEMPORARY DEPLOYMENT JOB FOR MR
deploy-mr-tmp-env:
image: node:20
stage: deploy
tags:
- sncf-runner
only:
- web
variables:
DIST_PATH: '$CI_PROJECT_DIR/storybook-static'
script:
- npm install -g @azure/static-web-apps-cli
- swa deploy --app-location ./ --output-location $DIST_PATH --verbose=silly --deployment-token $DEPLOYMENT_TOKEN --env $MR_DEPLOY_ENVIRONMENT