chore(travis): do not push (only test) unless on master

This commit is contained in:
Andy Joslin
2014-02-05 13:25:14 -05:00
parent 880cb1bf57
commit e7d62829e2

View File

@@ -13,7 +13,6 @@ function init {
export GH_ORG=driftyco
else
# For testing if we aren't on travis
export TRAVIS_BRANCH=master
export TRAVIS_BUILD_NUMBER=$RANDOM
export TRAVIS_PULL_REQUEST=false
export TRAVIS_COMMIT=$(git rev-parse HEAD)
@@ -41,6 +40,16 @@ function run {
# TODO Saucelabs settings need more tweaking before it becomes stable (sometimes it fails to connect)
# grunt karma:sauce --reporters=dots
# NOTE(ajoslin): this is the only way I have found to reliably detect if we are on master.
# `git rev-parse HEAD` changes to the name of a tag if we are pushing with a tag, as does TRAVIS_BRANCH.
# `git branch` gives us back line-seperated list of all the branches, with a * beside
# the active branch. So we grep the * then take out the spaces/asterisks and we have
# branch name.
GIT_BRANCH=$(git branch | grep '* ' | sed 's/ //g' | sed 's/\*//g')
if [[ "$GIT_BRANCH" != "master" ]]; then
echo "-- We are not on branch master, we are on branch $GIT_BRANCH. Will not push build out."
exit 0
fi
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then
echo "-- This is a pull request build; will not push build out."
exit 0