-
Notifications
You must be signed in to change notification settings - Fork 34
/
.gitlab-ci.yml
177 lines (154 loc) · 5.88 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
stages:
- test
- build
- deploy
- publish-docker-description
default:
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
variables:
KUBE_NAMESPACE: "faucetbots"
CI_REGISTRY: "docker.io/paritytech"
GIT_STRATEGY: fetch
CI_IMAGE: "docker.io/paritytech/eng-automation-ci:latest"
# BUILDAH_IMAGE is defined in group variables
BUILDAH_COMMAND: "buildah --storage-driver overlay2"
ARGOCD_IMAGE: argoproj/argocd:v2.5.5
DOCKERHUB_REPO: "paritytech"
IMAGE_NAME: docker.io/$DOCKERHUB_REPO/faucet
DOCKER_TAG: "${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}"
.common-refs: &common-refs
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "main"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
.pr-refs: &pr-refs
rules:
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
.publish-refs: &publish-refs
rules:
- if: $CI_COMMIT_REF_NAME == "main" # on commits to main branch
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # on tags (i.e. v1.0, v2.1rc1)
- if: $CI_COMMIT_REF_NAME =~ /^stg-v[0-9]+\.[0-9]+.*$/ # on staging tags
.deploy-stg-refs: &deploy-stg-refs
rules:
- if: $CI_COMMIT_REF_NAME == "main" # on commits to main branch
- if: $CI_COMMIT_REF_NAME =~ /^stg-v[0-9]+\.[0-9]+.*$/ # on staging tags
.deploy-prod-refs: &deploy-prod-refs
rules:
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # on tags (i.e. v1.0, v2.1rc1)
.kubernetes-env: &kubernetes-env
image: $CI_IMAGE
tags:
- kubernetes-parity-build
# template task for building and pushing an image
.build-push-docker-image: &build-push-docker-image
image: $BUILDAH_IMAGE
script:
- test "$Docker_Hub_User_Parity" -a "$Docker_Hub_Pass_Parity" ||
( echo "no docker credentials provided"; exit 1 )
- $BUILDAH_COMMAND build
--format=docker
--build-arg VCS_REF="${CI_COMMIT_SHA}"
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
--build-arg VERSION="${DOCKER_TAG}"
--build-arg PROJECT_NAME="${CI_PROJECT_NAME}"
--tag "$IMAGE_NAME:${DOCKER_TAG}"
--tag "$IMAGE_NAME:latest"
--file "$DOCKERFILE" .
- echo "$Docker_Hub_Pass_Parity" |
buildah login --username "$Docker_Hub_User_Parity" --password-stdin docker.io
- $BUILDAH_COMMAND info
- $BUILDAH_COMMAND push --format=v2s2 "$IMAGE_NAME:${DOCKER_TAG}"
- $BUILDAH_COMMAND push --format=v2s2 "$IMAGE_NAME:latest"
after_script:
- buildah logout --all
# test that docker image can build
.build-only-docker-image: &build-only-docker-image
image: $BUILDAH_IMAGE
script:
- $BUILDAH_COMMAND build
--format=docker
--build-arg VCS_REF="${CI_COMMIT_SHA}"
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
--build-arg PROJECT_NAME="${CI_PROJECT_NAME}"
--tag "$IMAGE_NAME:latest"
--file "$DOCKERFILE" .
- $BUILDAH_COMMAND info
#### stage: build
build-docker:
stage: build
<<: *pr-refs
<<: *kubernetes-env
<<: *build-only-docker-image
variables:
DOCKERFILE: "Dockerfile"
publish-docker:
stage: build
<<: *publish-refs
<<: *kubernetes-env
<<: *build-push-docker-image
variables:
DOCKERFILE: "Dockerfile"
#### stage: deploy
.deploy-with-argocd: &deploy-with-argocd
image: $ARGOCD_IMAGE
tags:
- kubernetes-parity-build
variables:
ARGOCD_OPTS: --grpc-web --grpc-web-root-path /$DOMAIN
script:
- argocd app list
- argocd app set $APP --helm-set substrate-faucet.image.tag="${DOCKER_TAG}"
- argocd app sync $APP
- argocd app wait $APP --timeout 180
deploy-versi:
stage: deploy
<<: *deploy-stg-refs
extends: .deploy-with-argocd
environment: versi
variables:
DOMAIN: parity-versi
APP: substrate-faucet-versi
deploy-westend:
stage: deploy
<<: *deploy-prod-refs
extends: .deploy-with-argocd
environment: westend
variables:
DOMAIN: parity-testnet
APP: substrate-faucet-westend
deploy-paseo:
stage: deploy
<<: *deploy-prod-refs
extends: .deploy-with-argocd
environment: paseo
variables:
DOMAIN: parity-testnet
APP: substrate-faucet-paseo
#### stage: publish-docker-description
.publish-docker-image-description:
stage: publish-docker-description
<<: *kubernetes-env
image: paritytech/dockerhub-description
variables:
DOCKER_USERNAME: $Docker_Hub_User_Parity
DOCKER_PASSWORD: $Docker_Hub_Pass_Parity
script:
- cd / && sh entrypoint.sh
publish-docker-image-description-faucet:
extends: .publish-docker-image-description
variables:
DOCKERHUB_REPOSITORY: $DOCKERHUB_REPO/$IMAGE_NAME
README_FILEPATH: $CI_PROJECT_DIR/Dockerfile.README.md
SHORT_DESCRIPTION: "Generic Faucet for Substrate based chains"
rules:
- if: $CI_COMMIT_REF_NAME == "main"
changes:
- Dockerfile.README.md