3 # Automatically deploy on gh-pages
8 TARGET_BRANCH="gh-pages"
10 # Save some useful information
11 REPO=$(git config remote.origin.url)
12 SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
13 SHA=$(git rev-parse --verify HEAD)
15 # Clone the existing gh-pages for this repo into out/
19 git checkout $TARGET_BRANCH
22 echo "Removing the current docs for master"
23 rm -rf out/master/ || exit 0
25 echo "Making the docs for master"
27 cp util/gh-pages/index.html out/master
28 python ./util/export.py out/master/lints.json
30 if [ -n "$TRAVIS_TAG" ]; then
31 echo "Save the doc for the current tag ($TRAVIS_TAG) and point current/ to it"
32 cp -r out/master "out/$TRAVIS_TAG"
34 ln -s "$TRAVIS_TAG" out/current
37 # Generate version index that is shown as root index page
39 cp util/gh-pages/versions.html out/index.html
45 dir for dir in os.listdir(".")\
46 if not dir.startswith(".") and os.path.isdir(dir)\
50 # 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
53 if [ -z "$TRAVIS_TAG" ]; then
54 echo "Generated, won't push"
59 # Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
60 ENCRYPTION_LABEL=e3a2d77100be
61 ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
62 ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
63 ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
64 ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
65 openssl aes-256-cbc -K "$ENCRYPTED_KEY" -iv "$ENCRYPTED_IV" -in .github/deploy_key.enc -out .github/deploy_key -d
66 chmod 600 .github/deploy_key
68 ssh-add .github/deploy_key
70 # Now let's go have some fun with the cloned repo
72 git config user.name "Travis CI"
73 git config user.email "travis@ci.invalid"
75 if [ -z "$(git diff --exit-code)" ]; then
76 echo "No changes to the output on this push; exiting."
81 git commit -m "Automatic deploy to GitHub Pages: ${SHA}"
83 # Now that we're all set up, we can push.
84 git push "$SSH_REPO" "$TARGET_BRANCH"