-
Notifications
You must be signed in to change notification settings - Fork 56
/
update-gh-pages.sh
executable file
·66 lines (57 loc) · 1.86 KB
/
update-gh-pages.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
#!/bin/bash
# Upload script taken from http://sleepycoders.blogspot.ie/2013/03/sharing-travis-ci-generated-files.html
set -e
set -u
# Debug info.
echo "Starting update-gh-pages.sh"
deploy_webui() {
JS_DIR=$1
WAR_PATH=bazel-bin/src/main/java/org/edumips64/
echo "Copying the JS code to ${JS_DIR}."
mkdir -p ${JS_DIR}
cp ${WAR_PATH}/webclient.war ${JS_DIR}
pushd .
cd ${JS_DIR}
unzip -o webclient.war
GIT_REV=$(git rev-parse HEAD)
echo "<br/><!--Built at Git revision ${GIT_REV}-->" >> edumips64.html
popd
}
if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then
echo "Travis invoked from a pull request. Not doing any deployment step."
return
fi
GH_PAGES_DIR=${HOME}/gh-pages
echo -n "Cloning gh-pages branch to ${GH_PAGES_DIR}.. "
git config --global user.email "travis@travis-ci.org"
git config --global user.name "Travis"
git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/lupino3/edumips64.git ${GH_PAGES_DIR} > /dev/null
echo "done."
echo "Git branch: $TRAVIS_BRANCH"
# Execute special per-branch actions.
if [ "$TRAVIS_BRANCH" == "master" ]; then
# Build JAR.
echo -n "Copying latest JAR to ${GH_PAGES_DIR}.. "
# TODO: remove hardcoded version.
cp bazel-genfiles/src/main/java/org/edumips64/edumips64-1.2.5.jar ${GH_PAGES_DIR}/edumips64-latest.jar
echo "done."
# Deploy the last version of the web UI.
deploy_webui ${GH_PAGES_DIR}
elif [ "$TRAVIS_BRANCH" == "webui-prototype" ]; then
echo -n "Copying web UI... "
mkdir -p ${GH_PAGES_DIR}/webui
rm -rf ${GH_PAGES_DIR}/webui/*
cp -Rf $HOME/webui/* ${GH_PAGES_DIR}/webui
echo "done."
fi
# Add, commit and push files.
cd ${GH_PAGES_DIR}
git add -f .
echo "Git status:"
git status
if ! git diff-index --quiet HEAD; then
echo -n "Committing files.. "
git commit -m "Travis build $TRAVIS_BUILD_NUMBER pushed to gh-pages"
git push -fq origin gh-pages > /dev/null
echo "done."
fi