-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
128 lines (120 loc) · 3.24 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
variables:
NODE_VERSION: "16.13.0"
npm_config_cache: "$CI_PROJECT_DIR/.npm"
NAMESPACE: "internal"
FF_USE_FASTZIP: "true"
ARTIFACT_COMPRESSION_LEVEL: "fast"
CACHE_COMPRESSION_LEVEL: "fast"
PROVISIONING_NAME: "dashboard"
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .npm
- node_modules
stages:
- dependencies
- test
- build
- docker
- deploy
dependencies:install:
stage: dependencies
image: node:$NODE_VERSION
script:
- yarn --frozen-lockfile
artifacts:
expire_in: 1 hour
paths:
- node_modules
tags:
- docker
test:lint:
stage: test
image: node:$NODE_VERSION
cache: {}
dependencies:
- dependencies:install
script:
- yarn npm-run-all eslint:report prettier:report stylelint:report typescript:report
tags:
- docker
docker:staging:
stage: docker
image: docker:20.10.16
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build . -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}
--build-arg DOCKER_ENVIRONMENT=staging
--build-arg CI_PIPELINE_IID=$CI_PIPELINE_IID
- docker push ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}
services:
- docker:20.10.16-dind
needs:
- test:lint
tags:
- docker
docker:production:
stage: docker
image: docker:20.10.16
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build . -t ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}
--build-arg DOCKER_ENVIRONMENT=production
--build-arg CI_PIPELINE_IID=$CI_PIPELINE_IID
- docker push ${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}
services:
- docker:20.10.16-dind
needs:
- test:lint
tags:
- docker
only:
- master
deploy:staging:
stage: deploy
image:
name: alpine/k8s:1.21.2
entrypoint: [""]
script:
- chmod go-r $KUBECONFIG_STAGING
- export KUBECONFIG=$KUBECONFIG_STAGING
- cd provisioning/overlays/staging;
- kustomize edit set image image=${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}
- kubectl diff -k ./ || true
- kubectl label configMaps -n $NAMESPACE -l currently-used-by-kustomize="true" --overwrite currently-used-by-kustomize="false"
- kubectl apply -k ./
- kubectl -n $NAMESPACE rollout status deployment/${PROVISIONING_NAME}
- kubectl delete configMaps -n $NAMESPACE -l currently-used-by-kustomize="false"
tags:
- docker
environment:
name: frontend
url: https://$ENTIRE_HOSTNAME_STAGING
needs:
- docker:staging
only:
- develop
deploy:production:
stage: deploy
image:
name: alpine/k8s:1.21.2
entrypoint: [""]
script:
- chmod go-r $KUBECONFIG_PRODUCTION
- export KUBECONFIG=$KUBECONFIG_PRODUCTION
- cd provisioning/overlays/production;
- kustomize edit set image image=${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}
- kubectl diff -k ./ || true
- kubectl label configMaps -n $NAMESPACE -l currently-used-by-kustomize="true" --overwrite currently-used-by-kustomize="false"
- kubectl apply -k ./
- kubectl -n $NAMESPACE rollout status deployment/${PROVISIONING_NAME}
- kubectl delete configMaps -n $NAMESPACE -l currently-used-by-kustomize="false"
tags:
- docker
environment:
name: frontend
url: https://$ENTIRE_HOSTNAME_PRODUCTION
needs:
- docker:production
only:
- master