Good Git deployment using branches strategy with Heroku?

前端 未结 3 1373
南方客
南方客 2021-01-29 23:49

What is a good deployment strategy to use with Git + Heroku (Ruby on Rails)?

Currently, the way I work with my origin Git repository: All features (or \'stories\') are f

3条回答
  •  无人及你
    2021-01-30 00:12

    There are a variety of ways to go about this, and it really depends on your preference.

    I'll give you one possible strategy off the top of my head: Given you already have an automated staging setup that uses master, I would suggest creating a 'production' branch. When you want to promote a fix/feature to production, you would just merge the topic branch into your 'production' branch.

    git checkout production
    git pull . my-topic-branch
    (resolve any conflicts)
    

    When you are ready to actually push that code to your production server, you should tag the branch using a unique name (probably with a timestamp). Then you simply push the production branch to Heroku.

    git checkout production
    git tag release-200910201249
    

    I'd suggest creating a script or git alias to automate the tagging for timestamps, since using a consistent naming scheme is important. I use something like this:

    git config alias.dtag '!git tag release-`date "+%Y%m%d%H%M"`'
    

    That allows me to do just type git dtag when I want to tag a release with a timestamp.

    You can view you tags using git tag and view them using git show release-1234. For more information on tags, run git help tag. You may also find this Github guide on tagging helpful. I'd also recommend reading up other people's workflows (here's a nice writeup) and pick and choose what works for you.

提交回复
热议问题