Skip to content

Instantly share code, notes, and snippets.

@drnic
Created March 23, 2022 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drnic/b0be3d3bb27abb5635955bf93bed1b6a to your computer and use it in GitHub Desktop.
Save drnic/b0be3d3bb27abb5635955bf93bed1b6a to your computer and use it in GitHub Desktop.
#!/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