Heroku Release Tasks

Heroku runs a special release tasks file whenever your app deploys. Specifically, this happens if you deploy on the command line or if you deploy using the pipeline. With the pipeline, the release tasks runs twice: once when staging is built & and released, and then again when the staging slug is promoted to production.

1/ Add this line to your Procfile

release: ./release-tasks.sh

2/ Create a file for release-tasks.sh

You generally want to run schema (and data migrations, if you’re using my gem nonschema_migrations). Here’s a simple release-tasks.sh script that just runs your schema migrations:

## Step to execute
bundle exec rails db:migrate

# check for a good exit
if [ $? -ne 0 ]
# something went wrong; convey that and exit
exit 1

You will add this to your project simply by creating a file release-tasks.sh at the root of your deployed app.

If you are running my gem nonschema_migrations, you would use a setup rake task with additional tasks (for example, data:migrate) like so:

bundle exec rails db:migrate data:migrate