-
Notifications
You must be signed in to change notification settings - Fork 42
/
.gitlab-ci.yml
149 lines (135 loc) · 3.25 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
image: python:3.6-slim
variables:
COACH_TEMP_IMAGE: $CI_REGISTRY_IMAGE/ci/coach:$CI_COMMIT_SHORT_SHA
BOT_TEMP_IMAGE: $CI_REGISTRY_IMAGE/ci/bot:$CI_COMMIT_SHORT_SHA
stages:
- build requirements
- build temp images
- test style
- validate format
- test stories
- push
- deploy
.set_ssh_config: &set_ssh_config
before_script:
- apt-get update -y
- apt-get install sshpass -y
test style:
stage: test style
script:
- pip -V
- python -V
- pip install -r dev.requirements.txt
- flake8 --exclude venv
run dataset validator:
stage: validate format
image: $COACH_TEMP_IMAGE
script:
- cd coach/
- make run-validator
build requirements:
stage: build requirements
image: docker
tags:
- docker
services:
- docker:dind
script:
- docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD
- cd ./docker/bot
- ./build-base.sh publish
only:
refs:
- master
changes:
- ./docker/bot/requirements.txt
environment: homolog
build temp images:
stage: build temp images
image: docker
tags:
- docker
services:
- docker:dind
script:
- docker build . -f docker/bot/coach.Dockerfile -t lappis/coach:tais > /dev/null 2>&1 # Builds lappis/coach:tais
- docker build -f docker/bot/bot.Dockerfile -t $BOT_TEMP_IMAGE . # It uses lappis/coach:tais built locally
- docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker tag lappis/coach:tais $COACH_TEMP_IMAGE # Retags lappis/coach:tag to temp image
- docker push $COACH_TEMP_IMAGE # Pushes temp image to the gitlab registry (it will be pulled from gitlab and pushed to Dockerhub later)
- docker push $BOT_TEMP_IMAGE
only:
refs:
- pipeline_refactoring
- master
environment: homolog
test stories:
stage: test stories
image: docker
tags:
- docker
services:
- docker:dind
script:
- docker pull $BOT_TEMP_IMAGE
- docker run --rm $BOT_TEMP_IMAGE make test-stories
push coach:
stage: push
image: docker
tags:
- docker
services:
- docker:dind
script:
- docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD
- docker pull $COACH_TEMP_IMAGE
- docker tag $COACH_TEMP_IMAGE lappis/coach:tais
- docker push lappis/coach:tais
only:
- master
environment: homolog
push bot:
stage: push
image: docker
tags:
- docker
services:
- docker:dind
script:
- docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD
- docker pull $BOT_TEMP_IMAGE
- docker tag $BOT_TEMP_IMAGE lappis/bot:tais
- docker push lappis/bot:tais
only:
- master
environment: homolog
push web:
stage: push
image: docker
tags:
- docker
services:
- docker:dind
script:
- docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD
- docker build -f docker/web/web.Dockerfile -t lappis/bot-web:tais .
- docker push lappis/bot-web:tais
only:
- master
environment: homolog
deploy bot to homolog:
stage: deploy
<<: *set_ssh_config
environment: homolog
script:
- ./scripts/deploy_bot.sh $TAIS_SERVER_PASSWORD $TAIS_SERVER_IP
only:
- master
deploy web to homolog:
stage: deploy
<<: *set_ssh_config
environment: homolog
script:
- ./scripts/deploy_web.sh $TAIS_SERVER_PASSWORD $TAIS_SERVER_IP
only:
- master