Skip to main content

Run Tasks with Release Phase

Learning Objectives

After completing this unit, you'll be able to:

  • Describe how to set up release phase tasks.
  • Describe how to check activity and logs related to releases.

Use the Release Phase

The optional release phase makes it possible to run tasks before you deploy a new release.

Uses Cases

Common tasks executed during this phase include:

  • Send CSS, JS, and other assets to a content delivery network (CDN) or AWS S3 bucket.
  • Prime or invalidate cache stores.
  • Run database schema migrations.

Specify Release Phase Tasks

Your app can use the release process to run release phase tasks in a one-off dyno. To specify tasks, add them to the app’s Procfile. Add a release process type to the file, along with the command to execute.

For example, for a Django app, here's how to specify a database migration in your file:


release: python manage.py migrate

If you deploy Docker images to Heroku, learn more about using the release phase with Container Registry.

When Does the Release Phase Occur?

The release phase tasks execute with each new release, unless the release is caused by changes to an add-on's config vars. All of the following events create a release:

  • A successful app build
  • A change to the value of a config var
  • A pipeline promotion
  • A rollback
  • A release via the platform API
  • Provisioning a new add-on

App dynos don't start for a new release until the release phase finishes successfully. If a release phase task fails, the new release doesn't get deployed. 

Roll Back a Release

If you deploy buggy code to production, revert the relevant code changes locally with git revert and redeploy.

If you must roll back a release due to incorrect configuration or other Heroku platform-specific issues, use the heroku rollback command. This command rolls your app back to a previous v40 release:

heroku rollback v40

Rolled back to v40

If you don't specify a release number, your app rolls back by a single release.

The heroku rollback command creates a new release. This release copies the compiled slug and config vars of the release you're rolling back to.

Note

Warning:

Running on a rolled-back release is a temporary fix for a bad deployment. Commit a fix for your issue and push it to Heroku as soon as possible.

Check the Release Status

To check on the status of a release, including failed releases and releases that are pending due to a long-running release phase, run heroku releases.

heroku releases

=== example-app Releases - Current: v52

v53  Deploy ad7c527 release command failed        example@heroku.com

v52  Deploy b41eb7c                               example@heroku.com

v51  Deploy 38352d3                               example@heroku.com

Use the heroku releases:output command to see the output of a particular release phase execution:

heroku releases:output v40

--- Migrating db ---

INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.

INFO  [alembic.runtime.migration] Will assume transactional DDL.

Check the Release Logs

Access the logs associated with a release from the Activity tab of your app. Click View release log beside the release you want to view. 

Activity feed for a Heroku app showing successful builds and releases.

Resources 

Salesforce 도움말에서 Trailhead 피드백을 공유하세요.

Trailhead에 관한 여러분의 의견에 귀 기울이겠습니다. 이제 Salesforce 도움말 사이트에서 언제든지 새로운 피드백 양식을 작성할 수 있습니다.

자세히 알아보기 의견 공유하기