'Does post-deploy run only on review apps in Heroku?

The documentation on Review Apps in Heroku says:

The app.json file has a scripts section that lets you specify a postdeploy command. Use this to run any one-time setup tasks that make the app, and any databases, ready and useful for testing

Does that mean it never runs on production? what about staging? Does it run on production if I create a new production app from scratch?

I'm trying to find out how to generate sample data for my review apps, a post-deploy hook that seems to apply to my whole pipeline, and not just review apps, feels like the wrong place.



Solution 1:[1]

It was as easy as specifying it in environments -> review, like this:

{
  "env": {
    "RAILS_MASTER_KEY": {
      "description": "Rails master encryption key.",
      "required": true,
      "generator": "secret"
    },
  },
  "formation": {
    "web": {
      "quantity": 1,
      "size": "hobby"
    },
    "worker": {
      "quantity": 1,
      "size": "hobby"
    }
  },
  "addons": [
    {
      "plan": "heroku-postgresql"
    }
  ],
  "environments": {
    "review": {
      "scripts": {
        "postdeploy": "bundle exec rails db:seed"
      }
    }
  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pupeno