Skip to content

Instantly share code, notes, and snippets.

@ferrucc-io
Last active October 8, 2018 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferrucc-io/27cdf0d7ca055f70018449a08ac7c0ca to your computer and use it in GitHub Desktop.
Save ferrucc-io/27cdf0d7ca055f70018449a08ac7c0ca to your computer and use it in GitHub Desktop.
Turn your VPS into Heroku - Auto deploy on commit to master
#!/bin/bash
app=magehash
# worker=$app.worker # add workers if you have them
deploy_to="/home/deploy/$app/app"
timestamp=$(date "+%Y%m%d%H%M%S")
releases="/home/deploy/$app/releases"
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "Deploying master branch to $deploy_to and starting service $app"
git --work-tree=/home/deploy/$app/tmp --git-dir=/home/deploy/$app/src checkout -f
cd /home/deploy/$app/tmp
mkdir -p $releases/$timestamp
## Bash code you use to Deploy your app ##
supervisorctl restart $app
# supervisorctl restart $worker # Restart workers if you have workers
else
echo "Ref $ref successfully received. Doing nothing: only the master branch will be deployed."
fi
done
@ferrucc-io
Copy link
Author

This script is in magehash/src/hooks/post-receive where Magehash is the name of our app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment