/
.gitlab-ci.yml
95 lines (85 loc) · 1.94 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
image: sikalabs/ci
stages:
- build
- deploy dev
- test dev
- deploy prod
- test prod
variables:
GIT_CLEAN_FLAGS: -ffdx -e .kaniko-cache
TAG: $CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-$CI_PIPELINE_ID
IMAGE: $CI_REGISTRY_IMAGE:$TAG
DEV_RELEASE: $CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG
PROD_RELEASE: $CI_PROJECT_PATH_SLUG
DEV_HOST: $CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG.$BASE_DOMAIN
PROD_HOST: producation.$BASE_DOMAIN
build:
stage: build
image:
name: gcr.io/kaniko-project/executor:v1.9.0-debug
entrypoint: [""]
script:
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor
--context .
--dockerfile ./Dockerfile
--destination $IMAGE
--cache=true
--cache-dir .kaniko-cache
.deploy:
script:
- helm upgrade --install
$RELEASE
one-image --repo https://helm.sikalabs.io
--namespace $RELEASE
--create-namespace
--wait
--set image=$IMAGE
--set host=$HOST
- slu wait-for tls -a $HOST:443
deploy dev:
extends: .deploy
stage: deploy dev
variables:
HOST: $DEV_HOST
RELEASE: $DEV_RELEASE
environment:
name: $CI_COMMIT_REF_SLUG
url: https://$HOST
on_stop: stop dev
stop dev:
stage: deploy dev
variables:
GIT_STRATEGY: none
RELEASE: $DEV_RELEASE
script:
- helm uninstall $RELEASE --namespace $RELEASE
when: manual
environment:
name: $CI_COMMIT_REF_SLUG
action: stop
test dev:
stage: test dev
script:
- curl -s https://$DEV_HOST
.prod:
rules:
- if: $CI_COMMIT_TAG
deploy prod:
extends:
- .deploy
- .prod
stage: deploy prod
variables:
HOST: $PROD_HOST
RELEASE: $PROD_RELEASE
environment:
name: production
url: https://$HOST
rules:
- if: $CI_COMMIT_TAG
test prod:
extends: .prod
stage: test prod
script:
- curl -s https://$PROD_HOST