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