Last active
December 29, 2015 03:09
-
-
Save justin-endler/7605834 to your computer and use it in GitHub Desktop.
General node.js Express app deployment script for Heroku.
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 | |
# requires that node app.js be contained in a Procfile | |
# ./heroku-deploy.sh <NODE_ENV> <local_branch_to_push> <app_to_destroy_if_redeploy> | |
# validate minimal input | |
if [ -z "$1" ] || [ -z "$2" ]; then | |
echo "Run with at least NODE_ENV and local_branch_to_push as arguments $1 and $2" | |
exit 1 | |
fi | |
# is this a redeploy?, if so destroy the current app | |
if [ -n "$3" ]; then | |
# destroy the app | |
heroku apps:destroy -a $3 --confirm $3 | |
fi | |
# create new app | |
heroku create | |
# configure new app | |
heroku config:set NODE_ENV=$1 | |
# push the app | |
git push heroku $2:master --force | |
# wait for node start up, then open it | |
sleep 3 | |
heroku open |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment