2 # Automatically deploy on gh-pages
7 TARGET_BRANCH="gh-pages"
9 # Save some useful information
10 REPO=$(git config remote.origin.url)
11 SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
12 SHA=$(git rev-parse --verify HEAD)
14 # Clone the existing gh-pages for this repo into out/
18 git checkout $TARGET_BRANCH
21 # Remove the current doc for master
22 rm -rf out/master/ || exit 0
24 # Make the doc for master
26 cp util/gh-pages/index.html out/master
27 python ./util/export.py out/master/lints.json
29 # Save the doc for the current tag and point current/ to it
30 if [ -n "$TRAVIS_TAG" ]; then
31 cp -r out/master "out/$TRAVIS_TAG"
33 ln -s "$TRAVIS_TAG" out/current
36 # Pull requests and commits to other branches shouldn't try to deploy, just build to verify
37 if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
39 if [ -z "$TRAVIS_TAG" ]; then
40 echo "Generated, won't push"
45 # Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
46 ENCRYPTION_LABEL=e3a2d77100be
47 ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
48 ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
49 ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
50 ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
51 openssl aes-256-cbc -K "$ENCRYPTED_KEY" -iv "$ENCRYPTED_IV" -in .github/deploy_key.enc -out .github/deploy_key -d
52 chmod 600 .github/deploy_key
54 ssh-add .github/deploy_key
56 # Now let's go have some fun with the cloned repo
58 git config user.name "Travis CI"
59 git config user.email "travis@ci.invalid"
61 if [ -z "$(git diff --exit-code)" ]; then
62 echo "No changes to the output on this push; exiting."
67 git commit -m "Automatic deploy to GitHub Pages: ${SHA}"
69 # Now that we're all set up, we can push.
70 git push "$SSH_REPO" "$TARGET_BRANCH"