-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path.builddocs.sh
executable file
·54 lines (43 loc) · 1.29 KB
/
.builddocs.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
#!/bin/bash
set -o errexit -o nounset
echo "Preparing to build and deploy documentation"
if [[ -z ${GH_USER_NAME} || -z ${GH_USER_EMAIL} || -z ${GH_REF} ]]; then
echo "Missing environment variables. Aborting"
exit 1
fi;
SCRIPT_PATH="$(cd "$(dirname "$0")" && pwd -P)"
# Get the deploy key
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in deploy_key.enc -out deploy_key -d
chmod 600 deploy_key
eval `ssh-agent -s`
ssh-add deploy_key
# Get curent commit revision
rev=$(git rev-parse --short HEAD)
# Initialize gh-pages checkout
mkdir -p build/html
(
cd build/html
git init
git config user.name "${GH_USER_NAME}"
git config user.email "${GH_USER_EMAIL}"
git remote add upstream "git@${GH_REF}"
git fetch upstream
git reset --hard upstream/gh-pages
)
# Build the documentation
mkdocs build --clean
cp -r build/phpunit/coverage build/html/
cp -r build/api build/html/
# Commit and push the documentation to gh-pages
(
cd build/html
touch .
git add -A .
git commit -m "Rebuild pages at ${rev}"
git push -q upstream HEAD:gh-pages
)
echo "Completed deploying documentation"