Created
March 23, 2022 21:06
-
-
Save drnic/b0be3d3bb27abb5635955bf93bed1b6a to your computer and use it in GitHub Desktop.
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 | |
help() { | |
echo "Usage: ./bin/commits-since-last-production-deploy [-a myapp ] [ -h ]" | |
exit 2 | |
} | |
if ! command -v heroku &>/dev/null; then | |
echo "Install 'heroku' CLI" | |
exit 1 | |
fi | |
if ! command -v jq &>/dev/null; then | |
echo "Install 'jq' CLI" | |
exit 1 | |
fi | |
while getopts 'a:h' opt; do | |
case "$1" in | |
-a) | |
appname="$2" | |
shift 2 | |
;; | |
-h | --help) | |
help | |
exit 2 | |
;; | |
esac | |
done | |
last_deploy_result=$(heroku releases ${appname:+-a $appname} --json | jq -r ".[0].description") | |
if [[ $last_deploy_result =~ ^(Deploy (.*)) ]]; then | |
sha="${BASH_REMATCH[2]}" | |
git log "$sha"..HEAD "$@" | |
else | |
echo "Last deploy to production did not succeed" | |
echo "--> $last_deploy_result" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment