Check Heroku environment before deploying

Implements a part of #2487.