-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
59 lines (49 loc) · 1.42 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
image: docker:git
services:
- docker:dind
stages:
- build
- test
- release
- deploy
variables:
SERVER_TEST_IMAGE: registry.gitlab.com/fernandocagale/seneca-service-webapi:$CI_BUILD_REF_NAME
SERVER_RELEASE_IMAGE: registry.gitlab.com/fernandocagale/seneca-service-webapi:latest
SERVER_NGINX_IMAGE: registry.gitlab.com/fernandocagale/seneca-service-webapi:nginx
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
build-server:
stage: build
script:
- docker build --pull -t $SERVER_TEST_IMAGE .
- docker push $SERVER_TEST_IMAGE
test-server:
stage: test
script:
- echo "Test"
release-nginx:
stage: release
script:
- docker build --pull -t $SERVER_NGINX_IMAGE ./nginx
- docker push $SERVER_NGINX_IMAGE
only:
- master
release-server:
stage: release
script:
- docker pull $SERVER_TEST_IMAGE
- docker tag $SERVER_TEST_IMAGE $SERVER_RELEASE_IMAGE
- docker push $SERVER_RELEASE_IMAGE
only:
- master
deploy:
stage: deploy
before_script:
- apk add --update openssh
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/id_rsa && chmod 600 ~/id_rsa && ssh-add ~/id_rsa
- mkdir -p ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
script:
- scp /builds/FernandoCagale/seneca-service-webapi/deploy/Makefile root@"$DEPLOY":~/deploy/webapi
- ssh root@"$DEPLOY" "cd ~/deploy/webapi; make"