-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
197 lines (174 loc) · 5.19 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
stages:
- test
- docker
- helm
- deploy
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
HLF_K8S_VERSION: 0.1.0-develop.58
sonarcloud-check:
stage: test
image: maven:3.6.3-jdk-11
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- cd backend
- mvn verify sonar:sonar -Dsonar.projectKey=xdev-tech_star
only:
- merge_requests
- master
- develop
helm-lint:
stage: test
image: registry.gitlab.com/xdev-tech/build/helm:3.1
script:
- helm registry login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- helm dependency update ./helm/star
- lint star helm/star --values helm/star/values-rte-dev.yaml
test:
image: registry.gitlab.com/xdev-tech/build/deploy:3.1
script:
- kubectl config get-contexts
- kubectl get pod -A
only:
- develop
docker-chaincode:
stage: docker
image:
name: registry.gitlab.com/xdev-tech/build/docker:3.1
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- build_with_helm_tag $CI_REGISTRY_IMAGE/chaincode helm/star chaincode
docker-keycloak:
stage: docker
image:
name: registry.gitlab.com/xdev-tech/build/docker:3.1
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- build_with_helm_tag $CI_REGISTRY_IMAGE/keycloak helm/star keycloak
docker-backend:
stage: docker
image:
name: registry.gitlab.com/xdev-tech/build/docker:3.1
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- build_with_helm_tag $CI_REGISTRY_IMAGE/backend helm/star backend
docker-frontend:
image:
name: registry.gitlab.com/xdev-tech/build/earthly:3.2
stage: docker
script:
- echo $DOCKER_HUB_PASSWORD | docker login -u $DOCKER_HUB_USER --password-stdin
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- earthly-daemonless --ci --push ./frontend/+docker $(tag-opts helm/star)
helm:
stage: helm
image: registry.gitlab.com/xdev-tech/build/helm:3.1
script:
- helm registry login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- helm dependency update ./helm/star
# .keycloak.image.tag
- build $CI_REGISTRY_IMAGE/helm/star ./helm/star
.deploy_star:
stage: deploy
image: registry.gitlab.com/xdev-tech/build/deploy:3.1
variables:
script:
- chmod 600 $KUBECONFIG
- dockerhublogin
- star_version=`yq eval .version helm/star/Chart.yaml`
- if [ -z "$CI_COMMIT_TAG" ]; then star_version=$star_version-$CI_COMMIT_REF_SLUG; fi
- helm repo add hlf-k8s https://gitlab.com/api/v4/projects/30449896/packages/helm/dev
- helm repo update
- kubectl delete -n ${CI_ENVIRONMENT_NAME} job --all
# orderer
- helm upgrade --install --wait --timeout 8m --version $HLF_K8S_VERSION
$(yq e .releaseName helm/hlf-ord/values-${CI_ENVIRONMENT_NAME}.yaml) hlf-k8s/hlf-ord
-n $(yq e .namespace helm/hlf-ord/values-${CI_ENVIRONMENT_NAME}.yaml)
--post-renderer kbldpp
--values helm/hlf-ord/values-${CI_ENVIRONMENT_NAME}.yaml
# peers
- helm upgrade --install --wait --timeout 8m --version $HLF_K8S_VERSION
peer1 hlf-k8s/hlf-peer
-n ${CI_ENVIRONMENT_NAME}
--post-renderer kbldpp
--values helm/hlf-peer/values-${CI_ENVIRONMENT_NAME}-peer1.yaml
--set "peer.chaincodes[0].image.tag=$star_version"
- env KUBECONFIG=$KUBECONFIG2 helm upgrade --install --wait --timeout 8m --version $HLF_K8S_VERSION
peer2 hlf-k8s/hlf-peer
-n ${CI_ENVIRONMENT_NAME}
--post-renderer kbldpp
--values helm/hlf-peer/values-${CI_ENVIRONMENT_NAME}-peer2.yaml
--set "peer.chaincodes[0].image.tag=$star_version"
# star
- helm dependency update ./helm/star
- helm upgrade --install --wait --timeout 8m
star ./helm/star
-n ${CI_ENVIRONMENT_NAME}
--post-renderer kbldpp
--values helm/star/values-${CI_ENVIRONMENT_NAME}.yaml
--values "$USERS"
--set image.tag=$star_version
--set keycloak.image.tag=$star_version
--set mail.username=$SMTP_USER
--set mail.password=$SMTP_PASSWORD
# testing
deploy-enedis-testing:
extends: .deploy_star
environment:
name: enedis-testing
only:
- develop
deploy-rte-testing:
extends: .deploy_star
environment:
name: rte-testing
only:
- develop
deploy-producer-testing:
extends: .deploy_star
environment:
name: producer-testing
only:
- develop
# staging
deploy-enedis-staging:
extends: .deploy_star
environment:
name: enedis-staging
only:
- staging
deploy-rte-staging:
extends: .deploy_star
environment:
name: rte-staging
only:
- staging
deploy-producer-staging:
extends: .deploy_star
environment:
name: producer-staging
only:
- staging
# prod
deploy-enedis-prod:
extends: .deploy_star
environment:
name: enedis-prod
only:
- prod
deploy-producer-prod:
extends: .deploy_star
environment:
name: producer-prod
only:
- prod
deploy-rte-prod:
extends: .deploy_star
environment:
name: rte-prod
only:
- prod