-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
74 lines (59 loc) · 1.65 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
stages:
- test
- build
- deploy
test:
only:
- develop
- pushes
- merge_requests
services:
- docker:20.10.16-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
stage: test
image: docker:latest
before_script:
- ls -la
- docker --version
script:
- docker compose run --rm picto-backend ./mvnw test
after_script:
- docker compose down --rmi all
allow_failure: true # temporary allow failure for now
build:
services:
- docker:20.10.16-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
stage: build
image: docker:latest
before_script:
- docker --version
script:
- docker build --no-cache .
allow_failure: false
deploy:
stage: deploy
image: debian:latest
environment:
name: devel
url: https://picto.skni.umcs.pl/api/docs
only:
- develop
- feature/ci-cd
before_script:
- "command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )"
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -p $SSH_PORT $SSH_HOST >> ~/.ssh/known_hosts
- ssh -p $SSH_PORT $SSH_USER@$SSH_HOST "echo 'TEST CONNECTION'"
script:
- ssh -p $SSH_PORT $SSH_USER@$SSH_HOST "cd /home/gitlab-deploy/picto/backend && docker compose -f docker-compose.prod.yml down"
- ssh -p $SSH_PORT $SSH_USER@$SSH_HOST "cd /home/gitlab-deploy/picto/backend && git pull"
- ssh -p $SSH_PORT $SSH_USER@$SSH_HOST "cd /home/gitlab-deploy/picto/backend && docker compose -f docker-compose.prod.yml up --build --force-recreate --no-deps -d"
after_script:
- rm -rf ~/.ssh
allow_failure: false