forked from paritytech/polkadot-testnet-faucet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
207 lines (180 loc) · 6.39 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
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: node:16.10-alpine
BUILDAH_IMAGE: quay.io/buildah/stable:v1.27
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)
.deploy-stg-refs: &deploy-stg-refs
rules:
- if: $CI_COMMIT_REF_NAME == "main" # on commits to main branch
.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 bud
--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 info
- buildah push --format=v2s2 "$IMAGE_NAME:${DOCKER_TAG}"
- buildah 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 bud
--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" .
#### stage: test
check-linting:
stage: test
<<: *common-refs
<<: *kubernetes-env
script:
- apk add git==2.30.6-r0
- yarn --network-concurrency 1 --frozen-lockfile
- yarn typecheck && yarn format && yarn lint
check-tests:
stage: test
<<: *common-refs
<<: *kubernetes-env
script:
- apk add git==2.30.6-r0
- yarn --network-concurrency 1 --frozen-lockfile
- yarn test
#### 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-wococo:
stage: deploy
<<: *deploy-stg-refs
extends: .deploy-with-argocd
environment: wococo
variables:
DOMAIN: parity-testnet
APP: substrate-faucet-wococo
deploy-rococo:
stage: deploy
<<: *deploy-prod-refs
extends: .deploy-with-argocd
environment: rococo
variables:
DOMAIN: parity-testnet
APP: substrate-faucet-rococo
deploy-rococo-ink-docs:
stage: deploy
<<: *deploy-prod-refs
extends: .deploy-with-argocd
environment: rococo-ink-docs
variables:
DOMAIN: parity-testnet
APP: substrate-faucet-rococo-ink-docs
deploy-westend:
stage: deploy
<<: *deploy-prod-refs
extends: .deploy-with-argocd
environment: westend
variables:
DOMAIN: parity-testnet
APP: substrate-faucet-westend
#### stage: publish-docker-description
publish-docker-image-description:
stage: publish-docker-description
<<: *kubernetes-env
image: paritytech/dockerhub-description
variables:
DOCKERHUB_REPOSITORY: paritytech/faucet
DOCKER_USERNAME: $Docker_Hub_User_Parity
DOCKER_PASSWORD: $Docker_Hub_Pass_Parity
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
script:
- cd / && sh entrypoint.sh