Heroku Deploy Hook With Two Environments

We are using sentry in combination with Heroku and we would like to associate commits with sentry via the Heroku deploy hook.

In the Heroku integration on Sentry we can select the repository and environment to track our release on, but we can only make one deploy url. We need to track sentry releases for both staging and production so we can keep see commit data on both environments, but we can only make a deploy url for either staging or production, not both.

Is there some better way to track releases on both staging and production environments?

1 Like

I am having the same issue and wondering how to achieve the goal of triggering the release of staging and production separately.

1 Like

It appears that it can’t be done using the heroku webhook at the moment. You have to use the sentry cli or the API to specify the environment where you deploy the release.

For example, using the cli you could run this bash script as a “heroku-postbuild” script.

export SENTRY_ORG='your org'
export SENTRY_PROJECT='your project'
DIST='your dist folder'

RELEASE_NUM=$(sentry-cli releases propose-version)

# Create a release
sentry-cli releases new $RELEASE_NUM
    
# Associate commits with the release
sentry-cli releases set-commits --auto $RELEASE_NUM

# Upload sourcemaps
sentry-cli releases files $RELEASE_NUM upload-sourcemaps --ext ts --ext map $DIST

# Finalize and deploy the release
sentry-cli releases finalize $RELEASE_NUM
sentry-cli releases deploys $RELEASE_NUM new -e $ENVIRONMENT // <- here you can specify staging or production