Testing / previewing Github branches on dev server

I just switched from svn to github. My team and I run local tests, and we make changes and tests on the central dev server. Whenever we make changes to the repositories, I would like to automatically make changes to any branches of my repositories in the folders on my dev server. This will allow me and my team to check and view each other's code using our central dev server.

Ideally, I could map subdomains to these different industry directories. That is, if a branch was called by a "refactor", I can check it using http://refactor.devserver.com

I assume this could include a hook in my github configuration that runs the script on the dev server? Perhaps I need to use a ci server like Hudson?

Edit: I can easily run the script to pull out the main branch - I need to make sure that all the changed branches are separated from the individual root folders, so I can easily test any branch through my own subdomain. (Or a similar way to automatically deploy and test any changed branches)

Many thanks.

+7
source share
2 answers

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

I wanted the team to be able to unlock the code and immediately show it at the URL: http://branch-name.devserver.com

I set the vhost directives in apache conf to map subdomains to folders:

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

I enter 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 repository folder to the folder with the name of the branch so that it becomes the root folder of the virtual host of the subdomain.

 mv repos-name new-branch 

Then switch the repositories from the wizard to the new branch

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

Now it is available at http://new-branch.devserver.com

Then after I introduced the changes to the branch on github - I pull them to the dev server

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

Now - if I want the pull to happen automatically, I could configure the CI server to listen to the git hub hook, which triggers a trigger in each branch folder. Hudson seemed to be able to do this.


I was hoping to find a smarter way to do this:

  • Without cloning repositions many times
  • With a single command that effectively updates all branches or a hook that allows me to pull only to the updated branch
  • With a decent folder structure for each branch - so that I could test any branch at a specific URL without having to bind to the http config every time I enter the code
  • possibly automatically creating a root folder for new branches so that they are magically displayed on the dev server

Any further thoughts are welcome ...

+10
source

This can be done using Hudson if you have a specific automatic deployment procedure. In fact, I made a similar setup about a year ago - if the changes were transferred to the master hudson, unit tests were made and if they were successfully deployed for production.

+1
source

All Articles