Skip to content

Instantly share code, notes, and snippets.

@rhiroyuki
Last active April 15, 2019 16:41
Show Gist options
  • Save rhiroyuki/443a0f77280b0813d9aa7e556c61a090 to your computer and use it in GitHub Desktop.
Save rhiroyuki/443a0f77280b0813d9aa7e556c61a090 to your computer and use it in GitHub Desktop.
Heroku commands
HEROKU_ENVIRONMENT=staging
heroku maintenance:on --remote "$HEROKU_ENVIRONMENT"
heroku ps:scale --remote "$HEROKU_ENVIRONMENT" > dynoscales
heroku ps:scale $(heroku ps:scale --remote "$HEROKU_ENVIRONMENT" | sed -E 's/=([0-9]+):/=0:/g') --remote "$HEROKU_ENVIRONMENT"
git push "$HEROKU_ENVIRONMENT" HEAD:master
# You should check first if you need to run any other scrips before atempting to deploy to production
heroku run bundle exec rake db:migrate --remote "$HEROKU_ENVIRONMENT"
heroku ps:scale `cat dynoscales` --remote "$HEROKU_ENVIRONMENT"
heroku maintenance:off --remote "$HEROKU_ENVIRONMENT"
# Check postgres version
heroku pg:info
# Set maintenance on
heroku maintenance:{on|off}
# Save dyno formation state
heroku ps:scale > mydynoformation
# Scale dynos to 0
heroku ps:scale $(heroku ps:scale | sed -E 's/=([0-9]+):/=0:/g')
# Scale dynos back to their original state
heroku ps:scale `cat mydynoformation`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment