我希望能够将代码推送到 dev.myapp.com
进行测试,然后推送到 www.myapp.com
进行生产使用。 Heroku 可以做到这一点吗?
最佳答案
您与 Heroku 的接口(interface)本质上是一个 Git 分支。 Heroku gem 通过其 API 完成一些工作,但在您的 Git 存储库中,它只是一个新的远程分支。
heroku create yourapp # production
git br -D heroku # delete the default branch
heroku create staging-yourapp # staging
git br -D heroku # delete the default branch
在 Heroku 上设置多个应用程序后,您应该能够像这样配置 Git 存储库:
git remote add staging git@heroku.com:staging-yourapp.git
git push origin staging
git remote add production git@heroku.com:yourapp.git
git push origin production
我通常在“工作”分支工作,并使用 Github 作为我的 master。
假设您属于这种情况,您的部署工作流程可能类似于:
git co -b working
# do some work
# push to github:
git co master
git merge working
git push
# push to staging:
git co staging
git merge master
git push origin staging
# push to production
git co production
git merge master
git push origin production
关于deployment - 在 Heroku 上暂存实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1279787/