Skip to content

Instantly share code, notes, and snippets.

@nakosung
Created April 12, 2014 04:01
Show Gist options
  • Save nakosung/10518184 to your computer and use it in GitHub Desktop.
Save nakosung/10518184 to your computer and use it in GitHub Desktop.
git post-receive to automate deployment
#!/bin/sh
mkdir -p /home/ec2-user/var
PID=$(cat /home/ec2-user/var/gitrepo.pid)
kill -9 $PID
git --work-tree=/home/ec2-user/git-repo checkout -f
cd /home/ec2-user/git-repo
[ -s "/home/ec2-user/.nvm/nvm.sh" ] && . "/home/ec2-user/.nvm/nvm.sh" # This loads nvm
nvm use 0.10.26
nohup coffee app.coffee > /home/ec2-user/var/gitrepo.log 2>&1 &
echo $! > /home/ec2-user/var/gitrepo.pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment