deploying to a test server before production on heroku

荒凉一梦 提交于 2019-12-04 17:43:25

When you run git push heroku master 'heroku' identifies the remote repository you are pushing to. In your case 'heroku' seems to be a reference to your production server. Similarly you probably have an 'origin' remote pointing to github.

If you list your git remotes you'll probably see something like this:

> git remote -v 
heroku  git@heroku.com:heroku_app_name.git (fetch)
heroku  git@heroku.com:heroku_app_name.git (push)
origin  git@github.com:your_github_org/repo_name.git (fetch)
origin  git@github.com:your_github_org/repo_name.git (push)

To push to a different heroku app you can just add that app as a new git remote.

git remote add heroku-staging git@heroku.com:heroku_staging_app.git

Now you should be able to push to either remote as needed.

git push origin master //push to github
git push heroku-staging //deploy to staging
git push heroku master //deploy to production

In general I suggest that you should not be pushing to heroku manually. Hopefully you can have a continuous integration server watch github, run tests whenever you push changes, and deploy to staging only when your automated tests pass. You can then have a manually triggered CI task which pushes whichever commit is currently on staging to production as well (or even automate production deploys as well).

You can perform the same configuration using the heroku command line. That also gives you a good way to manage environment variables and other settings on both of your heroku apps: https://devcenter.heroku.com/articles/multiple-environments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!