Last active
August 29, 2015 14:23
-
-
Save mlocher/f167075ef83213484778 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/sh | |
# This codeship custom script depends on: | |
# - API_KEY env var from Heroku | |
# It uses the CI_COMMITTER_NAME value to determine which Heroku | |
# app to deploy to. Each developer has their own environment. | |
set -e | |
export HEROKU_API_KEY="${API_KEY}" | |
# default feature branch app | |
STAGING_APP_NAME="flinstone-environment" | |
# update STAGING_APP_NAME based on the name of the committer | |
if [ "${CI_COMMITTER_NAME}" = "Fred" ]; then STAGING_APP_NAME="freds-environment"; elif [ "${CI_COMMITTER_NAME}" = "Barney" ]; then STAGING_APP_NAME="barneys-environment"; fi | |
STAGING_APP_URL="${STAGING_APP_NAME}.herokuapp.com" | |
echo "${CI_COMMITTER_EMAIL},${CI_COMMITTER_NAME},${CI_COMMITTER_USERNAME},${STAGING_APP_URL}" | |
# Turn on Heroku maintenance mode | |
heroku maintenance:on --app ${STAGING_APP_NAME} | |
# Push to remote - force a push in all cases on feature branches | |
git remote add heroku git@heroku.com:${STAGING_APP_NAME}.git | |
git push heroku -f ${COMMIT_ID}:refs/heads/master | |
# run migrations and update static content | |
heroku_run "python manage.py collectstatic --noinput" ${STAGING_APP_NAME} | |
heroku_run "python manage.py migrate --noinput" ${STAGING_APP_NAME} | |
# Turn off Heroku maintenance mode | |
heroku maintenance:off --app ${STAGING_APP_NAME} | |
# check if the app is up and running | |
check_url "${STAGING_APP_URL}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment