Skip to content

Instantly share code, notes, and snippets.



Created Apr 15, 2014
What would you like to do?
Heroku deployment script
# Release script
# Launch script
echo -n "Releasing application. Please run this script outside of virtual machine. Continue ? y/n : "
read ok
if [ "$ok" = "y" ] || [ "$ok" = "Y" ]; then
# Input local source branch
echo -n "Enter local source branch to be released : "
read local_branch
# Input GitHub remote repositoty
echo -n "Enter remote GitHub repository name : "
read github_repository
# Select Heroku application
echo -n "Enter remote Heroku repository : "
read heroku_repository
# Select Heroku application
echo -n "Enter Heroku application name : "
read application
# Select environment type
echo -n "Select environment type (staging / production) : "
read environment
# Release application
echo "Releasing application on "$environment" environment..."
# Push selected branch on GitHub
echo "Pushing "$local_branch" on GitHub "$github_repository" repository..."
git push $github_repository $local_branch
# Enable maintenance mode on Heroku application
echo "Enabling maintenance mode on "$application" application ("$environment" environment)..."
heroku maintenance:on --app $application
# Code release
echo "Deploying "$local_branch" on Heroku "$application" ("$heroku_repository" remote repository / "$environment" environment)..."
git push $heroku_repository $local_branch:master
# Migrate remote database
echo "Migrating remote database..."
heroku run rake db:migrate --app $application
# Clean cache
echo "Cleaning server cache..."
heroku run --app $application rails runner -e production Rails.cache.clear
# Restart application
echo "Restart server on "$environment" environment ("$application" application)..."
heroku restart --app $application
# Disable maintenance mode
echo "Disabling maintenance mode on "$environment" environment ("$application" application)..."
heroku maintenance:off --app $application
# Exit message
echo "Application "$application" released on "$environment" environment !"
echo "OK, goodbye !"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.