Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will app.json post-deploy script run on production env as well as review apps?

I'm using Heroku + Rails 5.1. I just want my postdeploy script written in app.json to run only in Review Apps environment.

like image 944
alea12 Avatar asked Oct 16 '17 09:10

alea12


People also ask

How does app JSON work?

app. json is a manifest format for describing web apps. It declares environment variables, add-ons, and other information required to run an app on Heroku. This document describes the schema in detail.

What are review apps Heroku?

Review apps each have a unique URL you can share, making them a great way to propose, test, and merge changes to your code base. You can configure review apps to spin up automatically for each pull request, or you can create them manually from your app's Pipeline page in the Heroku Dashboard.


1 Answers

I have done something like this by setting a config var in my staging environment (the parent for my review apps) which tells my postdeploy that it is not in production. I added the cli webpack to app.json and inside my postdeploy I get the value of that config var and then conditionally execute code. In production, we set a different var.

You could also just check the $HEROKU_PARENT_APP_NAME inside the review app (you must have this env var defined in app.json for it to appear in review app), and if the parent app == staging (or whatever), don't execute whatever is in your post deploy

good luck, getting review apps to work right can be a huge pain

like image 82
BobbiMcRobbi Avatar answered Oct 09 '22 02:10

BobbiMcRobbi