-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
52 lines (45 loc) · 1.44 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
# Ops One AG - Gitlab CD example pipeline
# define the stages in this pipeline
stages:
- build
- deploy
# define the build stage
build_stage:
stage: build
# use node docker image as enviroment
image: node:14.15
script:
# install & build the NuxtJS application
- npm install
- npm run build
# define artifacts which are shared between stages
artifacts:
paths:
- .nuxt/
- node_modules/
# restrict to specific branch
only:
- master
# define the deploy stage
deploy_stage:
stage: deploy
# use our deploy image
image: debian:10
# install needed packages
# add the SSH key from the variable SSH_DEPLOY_KEY and disable StrictHostKeyChecking
before_script:
- apt-get update && apt-get install --yes --no-install-recommends rsync git openssh-client curl
- eval $(ssh-agent -s)
- ssh-add <(echo "${SSH_DEPLOY_KEY}")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
# deploy application and server configuration
- rsync --archive --delete ${CI_PROJECT_DIR}/ ${DEPLOY_USER}@${DEPLOY_SERVER}:~/opsone-demo/
- rsync --archive --delete ${CI_PROJECT_DIR}/cnf/ ${DEPLOY_USER}@${DEPLOY_SERVER}:~/cnf/
# restart Node.js and reload nginx configuration
- ssh ${DEPLOY_USER}@${DEPLOY_SERVER} nodejs-restart
- ssh ${DEPLOY_USER}@${DEPLOY_SERVER} nginx-reload
# restrict to specific branch
only:
- master