Skip to content

Instantly share code, notes, and snippets.

@venkatd
Last active November 3, 2016 18:36
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 venkatd/799f76214217a1759e65260f072543d4 to your computer and use it in GitHub Desktop.
Save venkatd/799f76214217a1759e65260f072543d4 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e -o pipefail
if [ "${TRAVIS_BRANCH}" == "master" ]; then
TARGET_APP_NAME="turtle-api"
echo "Backing up the database (if a migration is needed)"
heroku run "mix db.backup_before_migration" --app "${TARGET_APP_NAME}"
echo "Running migrations (if there are any)..."
heroku run "mix ecto.migrate" --app "${TARGET_APP_NAME}"
echo "Rebuilding subscribers (if needed)"
heroku run "mix es.rebuild_subscribers" --app "${TARGET_APP_NAME}"
echo "Setting maintenance mode 'off' on heroku's app"
heroku maintenance:off --app "${TARGET_APP_NAME}"
echo "Application ready again. YAY!"
fi
#!/bin/bash
set -e -o pipefail
if [ "${TRAVIS_BRANCH}" == "master" ]; then
TARGET_APP_NAME="turtle-api"
echo "Setting up '~/.ssh/config' to work with heroku."
cat >> ~/.ssh/config <<EOF
Host heroku.com
StrictHostKeyChecking no
CheckHostIP no
UserKnownHostsFile=/dev/null
EOF
# DOC: https://devcenter.heroku.com/articles/authentication#usage-examples
cat >> ~/.netrc <<EOF
machine api.heroku.com
login ${HEROKU_API_LOGIN}
password ${HEROKU_API_KEY}
EOF
chmod 600 ~/.netrc
echo "Installing heroku toolbelt"
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh
echo "Setting maintenance mode 'on' on heroku's app"
heroku maintenance:on --app "${TARGET_APP_NAME}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment