Skip to content

Instantly share code, notes, and snippets.

@levent
Last active April 6, 2017 12:01
Show Gist options
  • Save levent/890745dc7a85a70a373e2a9c93d343b2 to your computer and use it in GitHub Desktop.
Save levent/890745dc7a85a70a373e2a9c93d343b2 to your computer and use it in GitHub Desktop.
Bash script that checks heroku status before deploying
#!/bin/bash
# Deploy to heroku unless H10 App Crashed
#
# Requires:
# heroku cli
# jq https://stedolan.github.io/jq/
# - brew install jq
# - apt-get install jq
#
# Usage: ./bin/deploy <nameofremote>
# Usage: ./bin/deploy <nameofremote> <nameoflocalbranch>
set -e
if [ $# -eq 0 ]
then
echo "No deploy remote"
exit
elif [ $# -eq 1 ]
then
remote="$1"
branch="master"
elif [ $# -eq 2 ]
then
remote="$1"
branch="$2"
fi
check=`heroku status --json | jq '.status[].status' | grep -c green`
test $check -eq 3
git push $remote $branch:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment