Skip to content

Instantly share code, notes, and snippets.

@nafu
Last active June 2, 2016 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nafu/32d218a317b4b6e9afa5 to your computer and use it in GitHub Desktop.
Save nafu/32d218a317b4b6e9afa5 to your computer and use it in GitHub Desktop.
CircleCIでherokuのprebootの設定を自動で行う ref: http://qiita.com/nafu/items/4c480934871bbdfb56e9
deployment:
production:
branch: master
commands:
- NEED_MAINTENANCE_MODE=`./script/circleci.sh`; if [ $NEED_MAINTENANCE_MODE -eq 1 ]; then heroku features:disable preboot --app production; else heroku features:enable preboot --app production; fi
- NEED_MAINTENANCE_MODE=`./script/circleci.sh`; if [ $NEED_MAINTENANCE_MODE -eq 1 ]; then heroku maintenance:on --app production; fi
- NEED_MAINTENANCE_MODE=`./script/circleci.sh`; if [ $NEED_MAINTENANCE_MODE -eq 1 ]; then heroku scale worker=0 --app production; fi
- git push -f git@heroku.com:production.git $CIRCLE_SHA1:refs/heads/master
- NEED_MAINTENANCE_MODE=`./script/circleci.sh`; if [ $NEED_MAINTENANCE_MODE -eq 1 ]; then heroku run 'rake db:migrate' --app production; fi
- heroku run 'rake db:seed' --app production
- NEED_MAINTENANCE_MODE=`./script/circleci.sh`; if [ $NEED_MAINTENANCE_MODE -eq 1 ]; then heroku maintenance:off --app production; fi
- NEED_MAINTENANCE_MODE=`./script/circleci.sh`; if [ $NEED_MAINTENANCE_MODE -eq 1 ]; then heroku features:enable preboot --app production; fi
#!/bin/bash
# get compare SHA1
compare_url=$CIRCLE_COMPARE_URL
compare_ids=${compare_url#*compare/}
# set NEED_MAINTENANCE_MODE if schema.rb is changed
if git diff --name-only $compare_ids | grep -q 'schema.rb'; then
echo 1
else
echo 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment