Postdeploy only at Pull Requests

Viewed 268

I'm using Heroku Pipelines and what to run some scripts only when Heroku builds Review app. Now I use that line in my app.json:

"scripts": {
    "postdeploy": "php artisan database:fill-test-data"
}

But I don't want to fill database with test data when anybody clicks on Deploy to Heroku button, because postdeploy scripts run at any first deploy. I want to fill database with test data only at Pull Requests.

Heroku has only 1 command that executed only at Pull Requests, and it is pr-predestroy.

The command is prefixed with “pr-” because it is ONLY run as part of the pull request (PR) app flow.

But as far as I know there is no pr-postdeploy command. What can you suggest me to use as script command that will be executed only in Review apps created by Pull Requests?

Heroku Documentation: Review Apps

1 Answers

You could add an env var to the parent app (that it inherits from) that tells you it is a non-production app (i.e. staging or whatever) and then in your post-deply script, you could check if it that var is true

Your review app should not inherit from production app anyway, so assuming you are inheriting from a staging app or some other non-prod app, this should work.

let me know! I've struggled with review apps a lot

Related