Last active
August 29, 2015 14:18
-
-
Save kimihito/3ccbe9d97232eab5788a to your computer and use it in GitHub Desktop.
Shell Script for deploying to Heroku
This file contains hidden or 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/bash | |
# get current branch name | |
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
push_heroku_branch() | |
{ | |
git push -f heroku deploy-to-heroku:master | |
} | |
checkout_deploy_branch() | |
{ | |
echo "force-deploy to Heroku from $branch" | |
# checkout branch named "deploy-to-heroku" | |
git checkout -b deploy-to-heroku | |
} | |
delete_public_assets_files() | |
{ | |
# delete files already exist public/assets (using rake assets:precompile) | |
rm -rf public/assets | |
git add . | |
git commit -m 'remove public/assets' | |
} | |
assets_precompile() | |
{ | |
bundle exec rake assets:precompile | |
git add . | |
git commit -m 'deploy-to-heroku' | |
} | |
clean_up_branch() | |
{ | |
git checkout $branch | |
git branch -D deploy-to-heroku | |
echo "finish" | |
} | |
checkout_deploy_branch | |
delete_public_assets_files | |
assets_precompile | |
push_heroku_branch | |
clean_up_branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment