Last active
August 31, 2015 14:01
-
-
Save bennylope/42993351581b248a364b to your computer and use it in GitHub Desktop.
A script to chain Heroku commands for deploying Django projects
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
STAGINGAPP=staging-app-name | |
PRODUCTIONAPP=production-app-name | |
case "$1" in | |
staging) | |
APPNAME=$STAGINGAPP | |
;; | |
production) | |
APPNAME=$PRODUCTIONAPP | |
;; | |
promote) | |
heroku pipeline:diff --app=$STAGINGAPP | |
read -p "Is this ready to promote to production? (y/n) " CONFIRM | |
case "$CONFIRM" in | |
y) | |
;; | |
Y) | |
;; | |
*) | |
echo "Not promoting to production" | |
exit | |
;; | |
esac | |
printf "Promoting to production...\n" | |
heroku pipeline:promote --app=$STAGINGAPP | |
heroku run python myapp/manage.py migrate --app=$PRODUCTIONAPP | |
exit | |
;; | |
*) | |
usage | |
exit | |
;; | |
esac | |
case "$2" in | |
deploy) | |
git push heroku-$APPNAME master | |
heroku run python myapp/manage.py migrate --app=$PRODUCTIONAPP | |
exit | |
;; | |
dj) | |
heroku run python myapp/manage.py "${@:3}" --app=$APPNAME | |
exit | |
;; | |
esac | |
printf "\nExecuting in the $1 environment\n" | |
printf "heroku ${@:2} --app=$APPNAME\n\n" | |
heroku "${@:2}" --app="$APPNAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment