Last active
August 29, 2015 14:04
-
-
Save tonnylitao/47c9010cea4ced20ff42 to your computer and use it in GitHub Desktop.
test hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#------------------------------------------------------ | |
prework(){ | |
# Select the git format you want to use | |
GITFORMAT='%h' | |
echo "----------------------------------------------------" | |
# Enter a closing message | |
FOOTERMSG='All good, ready to deploy' | |
# ------------------------------------------------------ | |
# Start of the Script. Do not edit below this line. | |
git-update-server-info | |
# ------------------------------------------------------- | |
Colors() { | |
Escape="\033"; | |
BlackF="${Escape}[30m"; RedF="${Escape}[31m"; GreenF="${Escape}[32m"; | |
YellowF="${Escape}[33m"; BlueF="${Escape}[34m"; Purplef="${Escape}[35m"; | |
CyanF="${Escape}[36m"; WhiteF="${Escape}[37m"; | |
BlackB="${Escape}[40m"; RedB="${Escape}[41m"; GreenB="${Escape}[42m"; | |
YellowB="${Escape}[43m"; BlueB="${Escape}[44m"; PurpleB="${Escape}[45m"; | |
CyanB="${Escape}[46m"; WhiteB="${Escape}[47m"; | |
BoldOn="${Escape}[1m"; BoldOff="${Escape}[22m"; | |
ItalicsOn="${Escape}[3m"; ItalicsOff="${Escape}[23m"; | |
UnderlineOn="${Escape}[4m"; UnderlineOff="${Escape}[24m"; | |
BlinkOn="${Escape}[5m"; BlinkOff="${Escape}[25m"; | |
InvertOn="${Escape}[7m"; InvertOff="${Escape}[27m"; | |
Reset="${Escape}[0m"; | |
} | |
Colors; | |
echo -e "${WhiteF}-------------------------------------------------${Reset}" | |
GIT_WORK_TREE=$1 git checkout $2 -f | |
if [ ! -f $1/package.json ]; then | |
echo -e "${RedF}FAIL: Unable to find a package.json file.${Reset}" | |
exit 0 | |
fi | |
# Start the NPM install | |
echo "Starting NPM install." | |
cd $1 | |
# Check to make certain the NPM install will run and has no issues. | |
echo -e "${GreenF}" | |
NPMINSTALL=`npm install` | |
echo -e "${Reset}" | |
if [ "$NPMINSTALL" != "${string/not/}" ]; then | |
echo "---------------------------------------------------" | |
echo "NPM installed the following..." | |
echo "" | |
echo "$NPMINSTALL" | |
fi | |
echo "---------------------------------------------------" | |
echo -e "${GreenF}$FOOTERMSG${Reset}" | |
echo "----------------------------------------------------" | |
APP="$1bin/www" | |
echo $APP | |
sudo forever stop ${APP} | |
} | |
while read oldrev newrev refname | |
do | |
branch=$(git rev-parse --symbolic --abbrev-ref $refname) | |
if [ "master" == "$branch" ]; then | |
prework '/opt/node/beancloud/' 'master' | |
echo "----------------------------------------------------" | |
echo "production forever start ${APP}" | |
sudo NODE_ENV=production forever start -l /opt/node/beancloud/.forever/forever.log -e /opt/node/beancloud/.forever/err.log -a ${APP} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment