-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
47 lines (47 loc) · 1.75 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
image: ubuntu:20.04
variables:
GIT_SUBMODULE_STRATEGY: recursive # required for submodules
DEBIAN_FRONTEND: noninteractive
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- venv/
policy: pull-push
stages:
- deploy
deploy:
stage: deploy
before_script:
- apt-get update -qy
- apt-get install -y curl tidy optipng python3 python3-pip locales rsync nodejs npm openssh-client expect
- pip3 install virtualenv
- npm install -g n
- n latest
- echo "en_US UTF-8" > /etc/locale.gen
- locale-gen en_US.UTF-8
- export LANG=en_US.UTF-8
- export LANGUAGE=en_US:en
- export LC_ALL=en_US.UTF-8
script:
- if [ ! -n "$SERVER_SSH_KEY" ]; then exit 0; fi
- mkdir ~/.ssh
- chmod 700 ~/.ssh
- echo "$SERVER_SSH_CONFIG" > ~/.ssh/config
- echo "$SERVER_SSH_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- echo "$JUMPHOST_SSH_KEY" | tr -d '\r' > ~/.ssh/id_rsa_jumphost
- chmod 600 ~/.ssh/*
# Add the SSH passphrases to the agent
- eval `ssh-agent`
- FILENAME=`readlink -f ~/.ssh/id_rsa` SSHKEY="$SERVER_SSH_KEY_PASS" .ci-scripts/add-ssh-pass.exp
- FILENAME=`readlink -f ~/.ssh/id_rsa_jumphost` SSHKEY="$JUMPHOST_SSH_KEY_PASS" .ci-scripts/add-ssh-pass.exp
- chmod 600 ~/.ssh/id_rsa
- make setup
- make downloads # download e.g. live stats from Github
- make SITE=src/site-prod.yml
- make optimize-html
- echo "Deploying $CI_COMMIT_REF_NAME..."
- if [ "$CI_COMMIT_REF_NAME" = "master" ]; then export DIRECTORY=master; fi;
- if [ "$CI_COMMIT_REF_NAME" = "staging" ]; then export DIRECTORY=staging; fi;
# we deploy the main website
- if [ -n "$DIRECTORY" ]; then rsync --delete -avh build/ $SERVER_SSH_USER@$SERVER_SSH_HOSTNAME:$SERVER_SSH_DIRECTORY/$DIRECTORY; fi;