Skip to content

Instantly share code, notes, and snippets.

@tatethurston
Last active December 2, 2017 23:17
Show Gist options
  • Save tatethurston/17163b9d442f3f9ad92dbd8b200cb5b8 to your computer and use it in GitHub Desktop.
Save tatethurston/17163b9d442f3f9ad92dbd8b200cb5b8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
post_slack() {
SLACK_URL="TODO:_FILL_ME_IN"
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"text\": \"$1\"}" \
-s \
$SLACK_URL > /dev/null
echo "Posted \"$1\" in Slack."
}
git fetch --all
git checkout master
FILES=$(git diff origin/master heroku/master --name-only)
if [[ -z $FILES ]]; then
echo "Nothing to deploy."
else
echo "Changes detected."
post_slack ":ship:"
# Test for db changes
if ! echo "$FILES" | grep -q "sql"; then
echo "No database changes detected."
git push heroku master
echo "Deployed changes to Heroku."
else
echo "Database changes detected."
post_slack ":migrate:"
echo "Run 'bundle exec rake heroku:deploy'"
fi
fi
# Return to branch
git checkout --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment