#!/bin/bash set -e . /nail/workflow/pushlib.sh main() { PUSHBRANCH=$1 if [ -z "$STAGE" ]; then echo "You must specify the \$STAGE variable." exit 1 fi git fetch git checkout "$PUSHBRANCH" git reset --hard "origin/$PUSHBRANCH" separator MASTER_SHA=`git rev-parse --short origin/master` git log --graph --oneline --color origin/master^..HEAD | sed "/$MASTER_SHA/q" separator echo -e "${AQUA}*** push this deploy branch into master? ***${NORMAL}" if yesno; then push-to-master $PUSHBRANCH DEPLOY_TAG="" get-deploy-tag $DEPLOY_TAG echo "Using $DEPLOY_TAG as the deploy tag" deploy-to-testopia $DEPLOY_TAG deploy-to-devc $DEPLOY_TAG deploy-to-devb $DEPLOY_TAG cleanup-deploy-branch $PUSHBRANCH reminder fi } yesno() { local answer read -p 'y/n? ' answer if [[ "$answer" == "y" ]]; then return 0 elif [[ "$answer" == "n" ]]; then return 1 else yesno fi } push-to-master() { PUSHBRANCH=$1 colorize git checkout master git pull origin master colorize git merge --no-ff "$PUSHBRANCH" git push origin master } get-deploy-tag() { DEPLOY_TAG=$1 DEPLOY_TAG=`deploy-srv-testopia -l --source="$STAGE" checkout_fulfillment | tail -1` echo -e "${AQUA}*** Confirm this is the correct deploy-tag ***${NORMAL}" echo -e "${RED}$DEPLOY_TAG${NORMAL}" if yesno; then return 0 else exit 1 fi } deploy-to-testopia() { DEPLOY_TAG=$1 colorize deploy-srv-testopia --no-prompt --source=$STAGE checkout_fulfillment $DEPLOY_TAG } deploy-to-devc() { DEPLOY_TAG=$1 colorize deploy-srv-devc --no-prompt --source=$STAGE checkout_fulfillment $DEPLOY_TAG } deploy-to-devb() { DEPLOY_TAG=$1 colorize deploy-srv-devb --no-prompt --source=$STAGE checkout_fulfillment $DEPLOY_TAG } cleanup-deploy-branch() { PUSHBRANCH=$1 # colorize git push origin :"$PUSHBRANCH" colorize git branch -D $PUSHBRANCH } reminder() { figlet "Don't forget..." echo "run the pushplans on the stage you didn't use!" } main $@