-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
34 lines (30 loc) · 1.53 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
variables:
SPHINX_IMAGE: sphinxdoc/sphinx:7.1.2
build_and_deploy:
image:
name: $SPHINX_IMAGE
entrypoint: ['']
before_script:
# Install additional dependencies into the base image.
- pip install sphinx-rtd-theme
- apt-get update --quiet=2
- apt-get install --quiet=2 --assume-yes rsync sshpass
script:
# Build the documentation. On success, results are stored under 'docs/_build'.
- sphinx-build -a -E -b html docs/source docs/_build
# Deploy to the web server, either for previewing or for publication.
- DEPLOY_DIR=$WEB_SERVER_ROOT_DIR
- PREVIEW_TOP_DIR=$DEPLOY_DIR/preview/$GITLAB_USER_LOGIN
- |
if [ "$CI_COMMIT_REF_NAME" != "master" ]; then
DEPLOY_DIR=$PREVIEW_TOP_DIR/$CI_COMMIT_REF_NAME;
fi
# Deploy the contents of 'docs/_build/' to the web server's deploy directory.
- SSH_LOGIN_COMMAND="ssh -F /dev/null -o PreferredAuthentications=password -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o KexAlgorithms=+diffie-hellman-group1-sha1 -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -l $WEB_SERVER_USER"
- sshpass -e $SSH_LOGIN_COMMAND $WEB_SERVER_HOSTNAME "mkdir -p $DEPLOY_DIR"
- rsync --recursive --force --delete --rsh="sshpass -e $SSH_LOGIN_COMMAND" docs/_build/ $WEB_SERVER_HOSTNAME:$DEPLOY_DIR
# When deploying in production, remove all previews for this developer.
- |
if [ "$CI_COMMIT_REF_NAME" == "master" ]; then
sshpass -e $SSH_LOGIN_COMMAND $WEB_SERVER_HOSTNAME "rm -rf $PREVIEW_TOP_DIR";
fi