Skip to content

Instantly share code, notes, and snippets.

@aludvigsen
Created July 16, 2015 05:35
Show Gist options
  • Save aludvigsen/647d31d9ddbc37e96345 to your computer and use it in GitHub Desktop.
Save aludvigsen/647d31d9ddbc37e96345 to your computer and use it in GitHub Desktop.
Git post-receive hook deployment using node, npm and PM2
#!/bin/sh
export GIT_WORK_TREE="/var/www/project"
echo "--> Checking out..."
git --work-tree=$GIT_WORK_TREE --git-dir=/var/repos/myrepo.git checkout -f
echo "--> NPM install..."
cd "$GIT_WORK_TREE"
npm install
echo "--> Restart server..."
pm2 restart {appname}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment