forked from CityOfZion/neo-mon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
87 lines (83 loc) · 2.55 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
stages:
- build
- deploy
variables:
DOCKER_HOST: tcp://docker-dind.docker:2375
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
build:
stage: build
image: docker:latest
only:
- develop
- master
script:
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- echo CI_COMMIT_SHA=$CI_COMMIT_SHA
- echo CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA
- echo CI_BUILD_REF=$CI_BUILD_REF
- IMAGE_TAG=$IMAGE_TAG.$CI_COMMIT_SHA
- echo IMAGE_TAG=$IMAGE_TAG
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
tags:
- build-internal
deploy:
image: lachlanevenson/k8s-kubectl:latest
environment:
name: mainnet
url: https://monitor.mainnet.bolchain.net
tags:
- deploy-mainnet
variables:
ENV_SLUG: mainnet
only:
- master
- develop
stage: deploy
when: manual
before_script:
- echo -n $KUBE_CONFIG | base64 -d > `pwd`/kube-config
- export KUBECONFIG=`pwd`/kube-config
script:
- IMAGE_TAG=$IMAGE_TAG.$CI_COMMIT_SHA
- echo IMAGE_TAG=$IMAGE_TAG
- kubectl version
- kubectl cluster-info
- cd manifests/
- sed -i -e "s~__CI_BUILD_REF_SLUG__~${CI_ENVIRONMENT_SLUG}~" -e "s~__CI_ENV_SLUG__~${ENV_SLUG}~" deployment.yaml service.yaml ingress.yaml
- sed -i "s~__VERSION__~${CI_COMMIT_REF_NAME}~" deployment.yaml ingress.yaml service.yaml
- sed -i "s~__CI_IMAGE_TAG__~${IMAGE_TAG}~" deployment.yaml
- kubectl apply -f deployment.yaml
- kubectl apply -f service.yaml
- kubectl apply -f ingress.yaml
- kubectl rollout status -f deployment.yaml
- kubectl get all,ing -l app=${CI_ENVIRONMENT_SLUG}
deploy_testnet:
image: lachlanevenson/k8s-kubectl:latest
environment:
name: testnet
url: https://monitor.testnet.bolchain.net
tags:
- deploy-testnet
variables:
ENV_SLUG: testnet
only:
- master
- develop
stage: deploy
when: manual
script:
- IMAGE_TAG=$IMAGE_TAG.$CI_COMMIT_SHA
- echo IMAGE_TAG=$IMAGE_TAG
- kubectl version
- kubectl cluster-info
- cd manifests/
- sed -i -e "s~__CI_BUILD_REF_SLUG__~${CI_ENVIRONMENT_SLUG}~" -e "s~__CI_ENV_SLUG__~${ENV_SLUG}~" deployment.yaml service.yaml ingress.yaml
- sed -i "s~__VERSION__~${CI_COMMIT_REF_NAME}~" deployment.yaml ingress.yaml service.yaml
- sed -i "s~__CI_IMAGE_TAG__~${IMAGE_TAG}~" deployment.yaml
- kubectl apply -f deployment.yaml
- kubectl apply -f service.yaml
- kubectl apply -f ingress.yaml
- kubectl rollout status -f deployment.yaml
- kubectl get all,ing -l app=${CI_ENVIRONMENT_SLUG}