Testing/previewing Github branches on a dev server

I've just moved from svn to github. Me and my team run local tests and we commit changes and test on a central dev server. Whenever we push changes to the repos I would like to automatically pull changes to any branches of my repos into folders on my dev server. This would enable me and my team to test and preview each others code using our central dev server.

Ideally, I could then map subdomains onto these different branch directories. Ie If the branch was called 'refactor' i might check it using http://refactor.devserver.com

I guess this might involve a hook in my github configuration that triggers a script on the dev server? Perhaps i need to use a ci server like Hudson?

Edit : I can easily trigger a script to pull the master branch - what I need to do is pull any changed branches to separate root folders, so I'm able to test any branch easily through it's own subdomain. (Or some similar way to deploy and test any changed branches automatically)

Many thanks.


Here is part of the answer to my own question...

I wanted the team to be able to fork the code and instantly be able to show it on a url like this : http://branch-name.devserver.com

I set up vhost directives in apache conf to map sub domains to folders :

<VirtualHost *:80>
        ServerName www.devserver.com
        ServerAlias *.devserver.com
        VirtualDocumentRoot /var/www/devserver/%1/
</VirtualHost>

I branch the code in github or on my local machine.
Then run these commands on the dev server

cd /var/www/devserver
git clone git@github.com:/user-name/repos-name

Move the cloned repos folder to a folder named the branch name so it becomes the root folder of the subdomain virtual host.

mv repos-name new-branch

Then switch the repos from master to the new branch

cd /var/www/devserver/new-branch
git checkout new-branch

It's now available on http://new-branch.devserver.com

Then after I've pushed changes to the branch on github - I pull them on the dev server

cd /var/www/devserver/new-branch
git pull

Now - if I want the pull to happen automatically I could setup a CI server to listen for a git hub hook which would trigger a pull in each branches folder. Looks like Hudson could do this.


I'd hoped to find a smarter way to do this :

  • Without cloning the repos many times
  • With a single command that updates all branches efficiently or a hook that lets me pull to only the branch that was updated
  • With a decent folder structure for each branch - so I could test any branch on a specific url without having to mess about with http config every time I branch the code
  • possibly automatically creating a root folder for new branches so that they would magically appear on the dev server
  • Any further thoughts welcome...


    It can certainly be done using Hudson if you have some automatic deploy procedure defined. In fact I have made a similar setup about a year ago - if changes were pushed into master Hudson made unit tests and if successful deployed to staging.

    链接地址: http://www.djcxy.com/p/90490.html

    上一篇: 我如何克隆多个git存储库。 如果它是可能的?

    下一篇: 在开发服务器上测试/预览Github分支