Last active
April 6, 2017 12:01
-
-
Save levent/890745dc7a85a70a373e2a9c93d343b2 to your computer and use it in GitHub Desktop.
Bash script that checks heroku status before deploying
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 | |
# 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