Skip to content

Instantly share code, notes, and snippets.

@kimihito
Last active August 29, 2015 14:18
Show Gist options
  • Save kimihito/3ccbe9d97232eab5788a to your computer and use it in GitHub Desktop.
Save kimihito/3ccbe9d97232eab5788a to your computer and use it in GitHub Desktop.
Shell Script for deploying to Heroku
#!/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