Development process, deployment, GitHub

2019-06-28 01:35发布

问题:

I am trying to bed down a development process for our team.

We have 3/4 disperate developers working on our code base at any one time.

We have started using GIT and the idea is that is piece of work is more than a live fix, then they fork the master branch.

Everyone has their own dev environment on the server, and we have one staging environment which should at all times be a copy of the master branch.

Developers develop on their local, then merge back into the master branch, which should then push their changes to the staging server (I want to set up something like this).

If all is approved, then the changes should be copied live. I want to automate this somehow, not sure how exactly. We are using GitHub, so I'm sure there are automated deploy scripts out there.

We only have 1 live server though so it'd be nice if only changed files on the master branch could be deployed to the live server.

Any ideas how to do this?

Is this approach sound?

Any other comments/ warnings?

Is a load balancer necesary to do things like this?

回答1:

My company following nearest by this blog.

We create the master branch for production. My case is for web development.

Step we do is

Developer fork their feature/bug from master

git checkout -b feature/featureA
git checkout -b bug/B

With this way, we will got the fresh code with already in the released line. In staging server, we use testing branch. So, when any feature want to going test, it will merge to that branch

In staging server we use

git checkout testing
git pull

There are release branch handling the hot fix, every hot fix will merge to this branch before merge to master. The idea is that release branch will packing some commits before merge to master which if the problem occurs, it just use command like

git reset --hard HEAD^

for temporary.

Let see my full working Step

git checkout master # Go to Master
git checkout -b feature/New  # New branch

Email come from boss to fix critical bug

git stash 
git checkout master
git checkout -b hotfix/a

do things

git commit
git checkout release
git merge hotfix/a
git checkout master
git merge release # In case that you want to pack all ready to production

In production

git tag -d previous
git tag previous
git pull

Oops! not working

git checkout previous

New commit merged

git checkout master
git pull

Continue my job

git checkout feature/New
git stash pop #Restore workspace
git commit
git checkout testing # ready to mix a test
git merge feature/New

Ready to release the feature

git checkout release
git merge feature/New

This is because all things in testing branch ready to deploy. So, when merge all ready feature to release branch, now, you can make final test.

When everything now go production, we do

git checkout testing
git merge master
git checkout release
git merge master

Automate script

I think you may look into .git/hooks/post-commit.sample for hookup some script after you commit the code? anyway, I never use it.