forked from paritytech/substrate-api-sidecar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
115 lines (107 loc) · 3.78 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
# Gitlab-CI Workflow
# stages:
# build:
# - Runs on commits on master or tags that match the pattern v1.0, v2.1rc1
# deploy-staging:
# - Runs on commits on master or tags that match the pattern v1.0, v2.1rc1 (continues deployment)
# deploy-production:
# - Runs on tags that match the pattern v1.0, v2.1rc1 (manual deployment)
variables:
CONTAINER_REPO: "docker.io/parity/substrate-api-sidecar"
HELM_NAMESPACE: "substrate-api-sidecar"
HELM_RELEASE_NAME_1: "kusama-sidecar"
HELM_RELEASE_NAME_2: "polkadot-sidecar"
HELM_CUSTOM_VALUES_FILE_1: "values-kusama.yaml"
HELM_CUSTOM_VALUES_FILE_2: "values-polkadot.yaml"
HELM_REPO: "helm/"
DOCKERFILE_DIRECTORY: "./"
default:
before_script:
- |-
if [[ $CI_COMMIT_TAG =~ ^v[0-9]+\.[0-9]+.*$ ]]; then
export DOCKER_IMAGE_TAG="${CI_COMMIT_TAG}"
export BUILD_LATEST_IMAGE="true"
else
export DOCKER_IMAGE_TAG="${CI_COMMIT_SHORT_SHA}-beta"
fi
stages:
- build
- deploy-staging
- deploy-production
.dockerize: &dockerize
stage: build
image: quay.io/buildah/stable
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+.*$/' # # i.e. v1.0, v2.1rc1
when: always
- if: '$CI_COMMIT_REF_NAME == "master"'
when: always
tags:
- kubernetes-parity-build
.deploy-k8s: &deploy-k8s
image: paritytech/kubetools:3.5.3
script:
- |-
kubectl get cm helm-custom-values -n $HELM_NAMESPACE -o jsonpath='{.data.values-kusama\.yaml}' > values-kusama.yaml
kubectl get cm helm-custom-values -n $HELM_NAMESPACE -o jsonpath='{.data.values-polkadot\.yaml}' > values-polkadot.yaml
- helm upgrade
--install
--atomic
--timeout 120s
--namespace $HELM_NAMESPACE
--set image.repository="${CONTAINER_REPO}"
--set image.tag="${DOCKER_IMAGE_TAG}"
--values ${HELM_CUSTOM_VALUES_FILE_1}
${HELM_RELEASE_NAME_1} ${HELM_REPO}
- helm upgrade
--install
--atomic
--timeout 120s
--namespace $HELM_NAMESPACE
--set image.repository="${CONTAINER_REPO}"
--set image.tag="${DOCKER_IMAGE_TAG}"
--values ${HELM_CUSTOM_VALUES_FILE_2}
${HELM_RELEASE_NAME_2} ${HELM_REPO}
tags:
- kubernetes-parity-build
build:
<<: *dockerize
script:
- echo building "$CONTAINER_REPO:$DOCKER_IMAGE_TAG"
- |-
if [[ $BUILD_LATEST_IMAGE ]]; then
buildah bud \
--format=docker \
--tag "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" \
--tag "$CONTAINER_REPO:latest" "$DOCKERFILE_DIRECTORY"
else
buildah bud \
--format=docker \
--tag "$CONTAINER_REPO:$DOCKER_IMAGE_TAG" "$DOCKERFILE_DIRECTORY"
fi
- echo ${Docker_Hub_Pass_Parity} |
buildah login --username ${Docker_Hub_User_Parity} --password-stdin docker.io
- echo pushing "$CONTAINER_REPO:$DOCKER_IMAGE_TAG"
- |-
if [[ $BUILD_LATEST_IMAGE ]]; then
buildah push --format=v2s2 "$CONTAINER_REPO:$DOCKER_IMAGE_TAG"
buildah push --format=v2s2 "$CONTAINER_REPO:latest"
else
buildah push --format=v2s2 "$CONTAINER_REPO:$DOCKER_IMAGE_TAG"
fi
deploy-staging:
stage: deploy-staging
<<: *deploy-k8s
environment:
name: parity-stg
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+.*$/' # i.e. v1.0, v2.1rc1
- if: '$CI_COMMIT_REF_NAME == "master"'
deploy-production:
stage: deploy-production
<<: *deploy-k8s
environment:
name: parity-chains
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+.*$/' # i.e. v1.0, v2.1rc1
when: manual