How to create an app on Heroku that copies another app's config vars and add-ons?

293 Views Asked by At

I've created review apps successfully, and the review apps do have all the correct config vars and add-ons copied, but I can't get the review apps to persist, or to move to 'staging' in the pipeline. They are automatically deleted when a pull request is closed.

When I create a new app in the pipeline under 'staging', I don't see any way to import the production app's config vars or add-ons.

The way this used to be done was via heroku fork, but that is now deprecated. I have tried using the heroku fork plug-in, but I run into installation problems:

$ heroku plugins:install heroku-fork
Installing heroku-fork@latest... ⣽
Installing heroku-fork@latest... !
 ▸    yarn add heroku-fork@latest --non-interactive
 ▸    --mutex=file:/Users/priyamurthy/.local/share/heroku/plugins/yarn.lock
 ▸    --preferred-cache-folder=/Users/priyamurthy/Library/Caches/heroku/yarn
 ▸    --registry=https://cli-npm.heroku.com exited with code 1
 ▸    error An unexpected error occurred:
 ▸    "https://cli-npm.heroku.com/heroku-fork: Hostname/IP does not match
 ▸    certificate's altnames: Host: cli-npm.heroku.com. is not in the cert's
 ▸    altnames: DNS:*.herokuapp.com, DNS:herokuapp.com".
 ▸
 ▸    yarn add v1.3.2
 ▸    [1/4] Resolving packages...
 ▸    info If you think this is a bug, please open a bug report with the
 ▸    information provided in
 ▸    "/Users/priyamurthy/.local/share/heroku/plugins/yarn-error.log".
 ▸    info Visit https://yarnpkg.com/en/docs/cli/add for documentation about
 ▸    this command.

How do people do this pretty basic task?

1

There are 1 best solutions below

0
On

Don't know what is your use case but you can utilize Heroku Platform API during the build phase.

first you have to retrieve config vars from Staging:

GET https://api.heroku.com/apps/$STAGING_APP_ID_OR_NAME/config-vars

then update config vars on prod

PATCH https://api.heroku.com/apps/$PROD_APP_ID_OR_NAME/config-vars

Please refer to this page for more information https://devcenter.heroku.com/articles/platform-api-reference#config-vars

Do not use this approach during the release phase, each update on config vars will trigger a new release.