-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
52 lines (45 loc) · 2 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
# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/node/tags/
image: node:latest
# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
test_server:
before_script:
- apt-get update
- apt-get --yes --force-yes install rsync
only:
refs:
- develop
script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# 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
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
# sync the files and restart the app
- rsync -avrc --delete --exclude=.env "$PWD/" root@$SERVER_IP:/root/$PROJECT_NAME/
- ssh root@$SERVER_IP "cd /root/$PROJECT_NAME/; npm install; pm2 restart $PROJECT_NAME"
master_server:
before_script:
- apt-get update
- apt-get --yes --force-yes install rsync
only:
refs:
- master
script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
# 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
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
# sync the files and restart the app
- rsync -avrc --delete --exclude=.env "$PWD/" root@$SERVER_IP:/root/$PROJECT_NAME2/
- ssh root@$SERVER_IP "cd /root/$PROJECT_NAME2/; npm install; pm2 restart $PROJECT_NAME2"