Created
March 3, 2015 04:05
-
-
Save zmpeg/198bbd6e9eed2bb3ea3e to your computer and use it in GitHub Desktop.
Git post-receive deploy hook for simple node apps using screen. Place this in a file in a bare repo under hooks/post-receive.
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 | |
DEPLOY_DIR="$HOME/apps/my-app/" | |
SCREEN_NAME="my-app" | |
echo "Deploying" | |
GIT_WORK_TREE="${DEPLOY_DIR}" git checkout -f master | |
echo "Loading nvm, node, npm" | |
export NVM_DIR="/home/deploy/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm | |
echo "Running \`npm install\`" | |
cd $DEPLOY_DIR | |
npm install | |
echo "Stopping running app" | |
screen -X -S $SCREEN_NAME quit | |
echo "Starting app again" | |
screen -d -m -S $SCREEN_NAME ./app.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment