Last active
December 2, 2017 23:17
-
-
Save tatethurston/17163b9d442f3f9ad92dbd8b200cb5b8 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
#!/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