-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
148 lines (132 loc) · 4.38 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
stages:
- test
- build
- staging
- production
variables:
IMAGE_NAME: "docker.io/paritytech/command-bot"
CI_IMAGE: "docker.io/paritytech/command-bot:ci"
# BUILDAH_IMAGE is defined in group variables
BUILDAH_COMMAND: "buildah --storage-driver overlay2"
DOCKER_TAG: ${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}
DOCKERFILE: Dockerfile
default:
image: $CI_IMAGE
tags:
- kubernetes-parity-build
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
.test-refs: &test-refs
rules:
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
.publish-refs: &publish-refs
rules:
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
- if: $CI_COMMIT_REF_NAME =~ /^stg-v[0-9]+\.[0-9]+.*$/ # i.e. stg-v1.0, stg-v2.1rc1
- if: $CI_COMMIT_REF_NAME == "master"
.common-refs: &common-refs
rules:
- !reference [.test-refs, rules]
- !reference [.publish-refs, rules]
.production-refs: &production-refs
rules:
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
- if: $CI_COMMIT_REF_NAME == "master"
when: manual
test-lint:
<<: *common-refs
stage: test
script:
- yarn --immutable
- yarn lint
test-unit:
<<: *common-refs
stage: test
script:
- yarn --immutable
- yarn test:unit
test-integration:
<<: *common-refs
# for debug
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
expire_in: "1 day"
when: "on_failure"
paths:
- ./generated
stage: test
script:
- yarn --immutable
- yarn test:integration
# test that docker image can be built
build-docker:
stage: build
<<: *test-refs
image: $BUILDAH_IMAGE
script:
- $BUILDAH_COMMAND build
--format=docker
--tag "$IMAGE_NAME:$DOCKER_TAG"
--file Dockerfile .
build-push-docker-app:
stage: build
<<: *publish-refs
image: $BUILDAH_IMAGE
script:
- echo "$Docker_Hub_Pass_Parity" |
buildah login --username "$Docker_Hub_User_Parity" --password-stdin docker.io
- $BUILDAH_COMMAND build
--format=docker
--tag "$IMAGE_NAME:$DOCKER_TAG"
--file Dockerfile .
- $BUILDAH_COMMAND info
- $BUILDAH_COMMAND push --format=v2s2 "$IMAGE_NAME:$DOCKER_TAG"
after_script:
- buildah logout --all
push-docker-image-description:
stage: build
variables:
CI_IMAGE: paritytech/dockerhub-description
DOCKERHUB_REPOSITORY: paritytech/command-bot
DOCKER_USERNAME: $Docker_Hub_User_Parity
DOCKER_PASSWORD: $Docker_Hub_Pass_Parity
README_FILEPATH: $CI_PROJECT_DIR/Dockerfile.README.md
SHORT_DESCRIPTION: "command-bot provides interfaces for executing arbitrary commands on GitLab CI"
rules:
- if: $CI_COMMIT_REF_NAME == "master"
changes:
- Dockerfile.README.md
script:
- cd / && sh entrypoint.sh
#### App deployment
.deploy-k8s: &deploy-k8s
image: quay.io/argoproj/argocd:v2.7.9
variables:
ARGOCD_OPTS: --grpc-web --grpc-web-root-path /$ENVIRONMENT
APP: command-bot
environment:
name: $ENVIRONMENT
script:
- argocd app list
- argocd app set $APP --helm-set common.image.tag="$DOCKER_TAG"
- argocd app sync $APP
- argocd app wait $APP --timeout 180
tags:
- kubernetes-parity-build
deploy-stg:
stage: staging
extends: .deploy-k8s
<<: *publish-refs
variables:
ENVIRONMENT: parity-stg
deploy-production:
stage: production
extends: .deploy-k8s
<<: *production-refs
variables:
ENVIRONMENT: parity-prod