-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
180 lines (154 loc) · 3.82 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
image: node:18.17.0-alpine
include:
- project: "procivis/one/one-operations"
file:
- "gitlab/docker.gitlab-ci.yml"
- "gitlab/github.gitlab-ci.yml"
- "gitlab/ci-tools.gitlab-ci.yml"
variables:
YARN_CACHE_FOLDER: './.yarn/cache'
YARN_ENABLE_GLOBAL_CACHE: 'false'
GITHUB_PROJECT: "procivis/one-react-native-components"
workflow:
rules:
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG
stages:
- prepare
- test
- build
- publish
- deploy
- github
- sync_with_jira
.build-cache: &build-cache
key:
files:
- yarn.lock
- package.json
paths:
- node_modules/
- lib/
- ${YARN_CACHE_FOLDER}
policy: pull
.app_settings: &app_settings
- APP_VERSION=${APP_VERSION:-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA}
- IMAGE_NAME=$CI_REGISTRY_IMAGE/storybook
- IMAGE_TAG=$IMAGE_NAME:$APP_VERSION
.install-node-modules: &install-node-modules
- >
if [ -d ./node_modules ] && [ "$(ls -A ./node_modules)" ]; then
echo "node_modules exists and seems valid, not re-installing deps."
else
echo "node_modules does not exist or is not valid, re-installing deps."
apk add --update --no-cache --virtual .build-deps alpine-sdk libc6-compat gcompat bash
npm config set -- @procivis:registry https://${CI_SERVER_HOST}/api/v4/packages/npm/
npm config set -- //${CI_SERVER_HOST}/:_authToken ${CI_JOB_TOKEN}
npm config set -- //${CI_SERVER_HOST}/api/v4/packages/npm/:_authToken ${CI_JOB_TOKEN}
yarn global add node-gyp @mapbox/node-pre-gyp
yarn install --frozen-lockfile --network-concurrency 1
fi
.modules_setup:
cache:
<<: *build-cache
before_script:
- *install-node-modules
- *app_settings
.only_tag:
rules:
- if: $CI_COMMIT_TAG
.only_manual_tag:
rules:
- if: $CI_COMMIT_TAG
when: manual
.only_main:
rules:
- if: $CI_COMMIT_REF_NAME == "main"
before_script:
- *app_settings
build_deps:
stage: prepare
extends: .modules_setup
script:
- yarn prepare
cache:
policy: pull-push
lint:
stage: test
needs: [build_deps]
extends: .modules_setup
script:
- yarn lint
compile:
stage: test
needs: [build_deps]
extends: .modules_setup
script:
- yarn typescript
test:
stage: test
needs: [build_deps]
extends: .modules_setup
script:
- yarn test
build:storybook:
stage: build
image: node:16-alpine
needs: [build_deps]
extends:
- .modules_setup
- .only_main
script:
- yarn build-storybook
artifacts:
paths:
- storybook-static
publish:storybook:
stage: publish
needs:
- job: build:storybook
artifacts: true
extends:
- .docker_publish
- .only_main
publish:npm:private:
stage: deploy
script:
- npm config set @procivis:registry https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/
- npm config set //${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken ${CI_JOB_TOKEN}
- npm publish --verbose --access restricted --tag stable
extends:
- .modules_setup
- .only_tag
publish:npm:public:
stage: deploy
script:
- npm config set //registry.npmjs.org/:_authToken ${NPMJS_TOKEN}
- npm publish --verbose --access public
extends:
- .modules_setup
- .only_manual_tag
deploy:storybook:
stage: deploy
needs:
- publish:storybook
extends:
- .only_main
variables:
HELM_VALUES_FILE: values/app-components.dev.procivis-one.yaml
K8S_NAMESPACE: default
HELM_APP_NAME: react-native
HELM_PATH: charts/one-rn-components-chart
DEPLOY_IMAGE_TAG: $CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
trigger:
project: procivis/one/one-operations
branch: main
strategy: depend
github:push:
stage: github
extends:
- .ci-tool:open_source_release
set_jira_version:
stage: sync_with_jira
extends:
- .ci-tool:set_jira_version