-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
update.sh
executable file
·67 lines (52 loc) · 1.47 KB
/
update.sh
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
#! /bin/bash
set -e
set -x
# Switch locale to utf8, otherwise rawdog fails to load unicode names
export LC_ALL="C.UTF-8"
export LC_CTYPE="C.UTF-8"
./build.sh
if [[ "${TESTING}" == "true" ]]; then
# Use testing setup for Travis
REPO_SUFFIX="-test"
else
# Production setup
REPO_SUFFIX=""
fi
git clone https://github.com/planet-sympy/planet.sympy.org${REPO_SUFFIX}
cd planet.sympy.org${REPO_SUFFIX}
git config user.name "Docker"
git config user.email "[email protected]"
COMMIT_MESSAGE="Publishing site on $(date "+%Y-%m-%d %H:%M:%S")"
git checkout -t origin/gh-pages
rm -rf ./*
cp -r ../build/website/* .
if [[ "${TESTING}" != "true" ]]; then
echo "planet.sympy.org" > CNAME
fi
touch .nojekyll
git add -A .
git commit -m "${COMMIT_MESSAGE}"
echo "Deploying:"
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
eval "$(ssh-agent -s)"
set +x
if [[ "${SSH_PRIVATE_KEY}" == "" ]]; then
echo "Not deploying because SSH_PRIVATE_KEY is empty."
exit 0
fi
# Generate the private/public key pair using:
#
# ssh-keygen -f deploy_key -N ""
#
# then set the $SSH_PRIVATE_KEY environment variable in the CI (Travis-CI,
# GitLab-CI, ...) to the base64 encoded private key:
#
# cat deploy_key | base64 -w0
#
# and add the public key `deploy_key.pub` into the target git repository (with
# write permissions).
ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 --decode)
set -x
git push [email protected]:planet-sympy/planet.sympy.org${REPO_SUFFIX} gh-pages