forked from OpenFuturePlatform/open-api-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
75 lines (68 loc) · 1.64 KB
/
.gitlab-ci.yml
File metadata and controls
75 lines (68 loc) · 1.64 KB
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
stages:
- build
- deploy
- certificates
##############
# Build
##############
build:
stage: build
image: node:9.11.1
script:
- npm install
- npm run docs:build
cache:
paths:
- node_modules/
artifacts:
paths:
- public
except:
- schedules
################
# Deploy
################
.before_script: &before_deploy
- apt-get update -y && apt-get install openssh-client rsync -y
- eval $(ssh-agent -s)
- echo "$DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $DEPLOY_HOST >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
deploy-to-server:
image: ubuntu:18.04
stage: deploy
before_script: *before_deploy
script:
- rsync -avzhO --no-p --delete -e ssh public/ $DEPLOY_USER@$DEPLOY_HOST:/var/www/docs.openfuture.io/
environment:
name: production
url: https://docs.openfuture.io
only:
- master
except:
- schedules
################
# Certificates
################
certificates:
stage: certificates
before_script: *before_deploy
script:
- |
ssh ${DEPLOY_USER}@${DEPLOY_HOST} "
docker run --rm --name certbot \
-v /etc/letsencrypt:/etc/letsencrypt \
-v /var/www/certbot:/var/www/certbot \
-v /var/log/letsencrypt:/var/log/letsencrypt \
certbot/certbot \
certonly --webroot -w /var/www/certbot/ \
-d docs.openfuture.io \
--renew-by-default -m devops@zensoft.io --eff-email --agree-tos --manual-public-ip-logging-ok
"
- ssh ${DEPLOY_USER}@${DEPLOY_HOST} "sudo service nginx reload"
environment:
name: production
only:
- schedules