From e7d62829e24852396e1ff610c50a6b5ded274e4d Mon Sep 17 00:00:00 2001 From: Andy Joslin Date: Wed, 5 Feb 2014 13:25:14 -0500 Subject: [PATCH] chore(travis): do not push (only test) unless on master --- scripts/travis/ci.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/travis/ci.sh b/scripts/travis/ci.sh index 3df6adbd60..e074f4c88e 100755 --- a/scripts/travis/ci.sh +++ b/scripts/travis/ci.sh @@ -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