Created
June 5, 2012 02:43
-
-
Save smagch/2872208 to your computer and use it in GitHub Desktop.
post-update hook for node.js
This file contains hidden or 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/bash | |
branch=$(git rev-parse --symbolic --abbrev-ref $1) | |
DEPLOY_DIR=/var/www/dogazei.org/dogazei.org-latest/ | |
echo Update pushed to branch $branch | |
update () { | |
cd $DEPLOY_DIR || exit | |
unset GIT_DIR | |
git checkout -f | |
git pull | |
if [ -d node_modules ]; then | |
rm -rf node_modules | |
fi | |
version=`cat package.json | json version` | |
echo "version is" $version | |
name=`cat package.json | json name` | |
echo "name is" $name | |
npm install | |
cp ~/start.sh . || echo "no start.sh in home dir" | |
dist=../"$name$version" | |
if [ -d $dist ]; then | |
echo $dist already exists. | |
else | |
echo "make dir $name$version" | |
cp -R . $dist | |
fi | |
} | |
if [ $branch = "master" ]; then | |
echo "master updated about to pull changes in" $DEPLOY_DIR | |
update | |
fi | |
exec git update-server-info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment