Last active
October 8, 2018 21:33
-
-
Save ferrucc-io/27cdf0d7ca055f70018449a08ac7c0ca to your computer and use it in GitHub Desktop.
Turn your VPS into Heroku - Auto deploy on commit to master
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script is in magehash/src/hooks/post-receive where Magehash is the name of our app