@@ -13,11 +13,7 @@ SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
1313SHA=$( git rev-parse --verify HEAD)
1414
1515# Clone the existing gh-pages for this repo into out/
16- (
17- git clone " $REPO " out
18- cd out
19- git checkout $TARGET_BRANCH
20- )
16+ git clone --quiet --single-branch --branch " $TARGET_BRANCH " " $REPO " out
2117
2218echo " Removing the current docs for master"
2319rm -rf out/master/ || exit 0
@@ -27,35 +23,44 @@ mkdir out/master/
2723cp util/gh-pages/index.html out/master
2824python ./util/export.py out/master/lints.json
2925
30- if [ -n " $TRAVIS_TAG " ]; then
26+ if [[ -n " $TRAVIS_TAG " ] ]; then
3127 echo " Save the doc for the current tag ($TRAVIS_TAG ) and point current/ to it"
3228 cp -r out/master " out/$TRAVIS_TAG "
3329 rm -f out/current
3430 ln -s " $TRAVIS_TAG " out/current
3531fi
3632
3733# Generate version index that is shown as root index page
38- (
39- cp util/gh-pages/versions.html out/index.html
40-
41- cd out
42- python -c ' \
43- import os, json;\
44- print json.dumps([\
45- dir for dir in os.listdir(".")\
46- if not dir.startswith(".") and os.path.isdir(dir)\
47- ])' > versions.json
48- )
34+ cp util/gh-pages/versions.html out/index.html
35+ pushd out
36+
37+ cat << -EOF | python - > versions.json
38+ import os, json
39+ print json.dumps([
40+ dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir)
41+ ])
42+ EOF
43+ popd
4944
5045# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
51- if [ " $TRAVIS_PULL_REQUEST " != " false" ] || [ " $TRAVIS_BRANCH " != " $SOURCE_BRANCH " ]; then
46+ if [[ " $TRAVIS_PULL_REQUEST " != " false" ]] || [[ " $TRAVIS_BRANCH " != " $SOURCE_BRANCH " ] ]; then
5247 # Tags should deploy
53- if [ -z " $TRAVIS_TAG " ]; then
48+ if [[ -z " $TRAVIS_TAG " ] ]; then
5449 echo " Generated, won't push"
5550 exit 0
5651 fi
5752fi
5853
54+ # Now let's go have some fun with the cloned repo
55+ cd out
56+ git config user.name " Travis CI"
57+ git config user.email " travis@ci.invalid"
58+
59+ if git diff --exit-code --quiet; then
60+ echo " No changes to the output on this push; exiting."
61+ exit 0
62+ fi
63+
5964# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
6065ENCRYPTION_LABEL=e3a2d77100be
6166ENCRYPTED_KEY_VAR=" encrypted_${ENCRYPTION_LABEL} _key"
@@ -64,19 +69,9 @@ ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
6469ENCRYPTED_IV=${! ENCRYPTED_IV_VAR}
6570openssl aes-256-cbc -K " $ENCRYPTED_KEY " -iv " $ENCRYPTED_IV " -in .github/deploy_key.enc -out .github/deploy_key -d
6671chmod 600 .github/deploy_key
67- eval $( ssh-agent -s)
72+ eval " $( ssh-agent -s) "
6873ssh-add .github/deploy_key
6974
70- # Now let's go have some fun with the cloned repo
71- cd out
72- git config user.name " Travis CI"
73- git config user.email " travis@ci.invalid"
74-
75- if [ -z " $( git diff --exit-code) " ]; then
76- echo " No changes to the output on this push; exiting."
77- exit 0
78- fi
79-
8075git add .
8176git commit -m " Automatic deploy to GitHub Pages: ${SHA} "
8277
0 commit comments