-
Notifications
You must be signed in to change notification settings - Fork 37
/
.gitlab-ci.yml
82 lines (72 loc) · 2.24 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
image: docker:latest
services:
- docker:dind
stages:
- build
- test
- release
- deploy
variables:
SERVER_TEST_IMAGE: yamalight/bpwjs-server:$CI_BUILD_REF_NAME
CLIENT_TEST_IMAGE: yamalight/bpwjs-client:$CI_BUILD_REF_NAME
SERVER_RELEASE_IMAGE: yamalight/bpwjs-server:latest
CLIENT_RELEASE_IMAGE: yamalight/bpwjs-client:latest
before_script:
- docker login -u yamalight -p $CI_DOCKERHUB_PASSWORD
build-server:
stage: build
script:
- docker build --pull -t $SERVER_TEST_IMAGE ./server
- docker push $SERVER_TEST_IMAGE
build-client:
stage: build
script:
- docker build --pull -t $CLIENT_TEST_IMAGE ./client
- docker push $CLIENT_TEST_IMAGE
test-server:
stage: test
script:
- docker run -d --name expertsdb rethinkdb
- docker pull $SERVER_TEST_IMAGE
- docker run --link expertsdb:expertsdb -e EXPERTS_DB_URL=expertsdb $SERVER_TEST_IMAGE npm test
test-client:
stage: test
script:
- docker pull $CLIENT_TEST_IMAGE
- docker run -e TZ=Europe/Berlin $CLIENT_TEST_IMAGE npm test
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
release-client:
stage: release
script:
- docker pull $CLIENT_TEST_IMAGE
- docker tag $CLIENT_TEST_IMAGE $CLIENT_RELEASE_IMAGE
- docker push $CLIENT_RELEASE_IMAGE
only:
- master
deploy:
stage: deploy
only:
- master
when: manual
before_script:
# Install ssh-agent, ldap if not already installed
- apk add --update openssh
# Run ssh-agent (inside the build environment)
- eval $(ssh-agent -s)
# Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
- echo "$SSH_PRIVATE_KEY" > ~/id_rsa && chmod 600 ~/id_rsa && ssh-add ~/id_rsa
# For Docker builds disable host key checking. Be aware that by adding that
# you are suspectible to man-in-the-middle attacks.
# WARNING: Use this only with the Docker executor, if you use it with shell
# you will overwrite your user's SSH config.
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh root@codezen.net "cd /root/bpwjs.deploy; make deploy"