Last active
August 29, 2015 14:02
-
-
Save bodokaiser/600a2dd77ee31cfcb2af to your computer and use it in GitHub Desktop.
git post receive hook for nvm environments
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/bash | |
source $HOME/.bash_profile | |
set -u | |
set -e | |
# directory name | |
NAME=$(basename $(pwd) .git) | |
# working tree name | |
WORK=/srv/node/$NAME | |
# name of logs to share | |
LOGS=/var/log/node-$NAME.log | |
# copies file to working tree | |
echo -e "\n--> Updating $NAME" | |
mkdir -p $WORK && GIT_WORK_TREE=$WORK git checkout -f | |
# installs missing packages | |
echo -e "\n--> Installing packages" | |
cd $WORK && npm install | |
# outputs logs | |
echo -e "\n--> Service will be restarted" | |
service "node-$NAME" restart && cat $LOGS | tail -20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment