-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.example.yml
51 lines (48 loc) · 1.31 KB
/
.gitlab-ci.example.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
image: node:latest
# #
# This GitLab CI configuration requires Git and Docker in the server
# Also, project should be cloned to the server before first CI
#
# Required variables
# $PRIVATE_KEY - SSH Key
# $DEV_USER - Username to connect server
# $DEV_HOST - Hostname to connect server
# #
stages:
- install
- deploy
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$PRIVATE_KEY")
install:
stage: install
before_script:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
script:
- yarn install
artifacts:
name: 'artifacts'
untracked: true
expire_in: 30 mins
paths:
- .npm/
- node_modules/
- .yarn/
only:
refs:
# - master
# - develop
# - stage
dev_deploy:
stage: deploy
script:
- ssh $DEV_USER@$DEV_HOST "cd $DEV_PATH && git pull"
- ssh $DEV_USER@$DEV_HOST "cd $DEV_PATH && docker-compose build --no-cache"
- ssh $DEV_USER@$DEV_HOST "cd $DEV_PATH && docker-compose up -d"
- ssh $DEV_USER@$DEV_HOST "docker image prune -af"
only:
# - stage