-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdeploy.sh
More file actions
70 lines (61 loc) · 1.97 KB
/
deploy.sh
File metadata and controls
70 lines (61 loc) · 1.97 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
#!/bin/bash
# Deploy documentation to the github wiki
#
# Environment variables that may be of use:
#
# - GH_USER_NAME indicates the GitHub author name to use;
# - GH_USER_EMAIL indicates the email address for that author;
# - GH_REPO indicates the GitHub <user>/<repository_name> location;
# - GH_TOKEN is the personal security token to use for commits.
#
# All of the above are exported via the project .travis.yml file (with
# GH_TOKEN being encrypted and present in the `secure` key). The user details
# need to match the token used for this to work.
#
# The script should be run from the project root.
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
echo "This is a pull request. No deployment will be done."
exit 0
fi
if [[ "$TRAVIS_BRANCH" != "master" ]]; then
echo "Testing on a branch other than master. No deployment will be done."
exit 0
fi
if [[ "$DEPLOY_DOCS" != "true" ]]; then
echo "Ignoring deployment. No deployment will be done."
exit 0
fi
echo "... preparing deployment"
# Get curent commit revision
rev=$(git rev-parse --short HEAD)
echo "... revision: ${rev}"
# Initialize gh-pages checkout
mkdir -p ${TRAVIS_BUILD_DIR}/docs/build
(
echo "... setup build dir"
cd ${TRAVIS_BUILD_DIR}/docs/build
git init
git config user.name "Travis-CI"
git config user.email "${GH_USER_EMAIL}"
git remote add upstream "https://${GH_TOKEN}@github.com/${GH_REPO}.wiki.git"
git fetch upstream
git reset upstream/master
)
# Build the documentation
echo "... copying docs"
cp -rf ${TRAVIS_BUILD_DIR}/docs/wiki/* ${TRAVIS_BUILD_DIR}/docs/build/
# Commit and push the documentation
(
cd ${TRAVIS_BUILD_DIR}/docs/build
if [[ `git status --porcelain` ]]; then
echo "... commiting and pushing the docs"
touch .
git add -A .
git commit -m "Rebuild wiki at ${rev}"
git push -q upstream HEAD:master
else
echo "Ignoring deployment. No changes detected."
exit 0
fi
)
echo "... deployment ready"