@@ -0,0 +1,65 @@
1+#!/bin/bash
2+
3+set -e # Exit with nonzero exit code if anything fails
4+
5+SOURCE_BRANCH="dynamic"
6+TARGET_BRANCH="gh-pages"
7+OUT=dist-newstyle/hpc
8+
9+function doCompile {
10+ ./runTestsAndCoverage.sh
11+}
12+
13+# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
14+if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
15+ echo "Skipping deploy; just doing a build."
16+ doCompile
17+ exit 0
18+fi
19+
20+# Save some useful information
21+REPO=`git config remote.origin.url`
22+SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
23+SHA=`git rev-parse --verify HEAD`
24+
25+# Clone the existing gh-pages for this repo into $OUTt/
26+# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
27+git clone $REPO $OUT
28+cd $OUT
29+git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
30+cd ..
31+
32+# Clean out existing contents
33+rm -rf $OUT/**/* || exit 0
34+
35+# Run our compile script
36+doCompile
37+
38+# Now let's go have some fun with the cloned repo
39+cd $OUT
40+git config user.name "Travis CI"
41+git config user.email "$COMMIT_AUTHOR_EMAIL"
42+
43+# If there are no changes to the compiled out (e.g. this is a README update) then just bail.
44+if [ -z `git diff --exit-code` ]; then
45+ echo "No changes to the output on this push; exiting."
46+ exit 0
47+fi
48+
49+# Commit the "changes", i.e. the new version.
50+# The delta will show diffs between new and old versions.
51+git add .
52+git commit -m "Deploy to GitHub Pages: ${SHA}"
53+
54+# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
55+ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
56+ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
57+ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
58+ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
59+openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in deploy_key.enc -out deploy_key -d
60+chmod 600 deploy_key
61+eval `ssh-agent -s`
62+ssh-add deploy_key
63+
64+# Now that we're all set up, we can push.
65+git push $SSH_REPO $TARGET_BRANCH