在开发服务器上测试/预览Github分支 [英] Testing/previewing Github branches on a dev server

查看:128
本文介绍了在开发服务器上测试/预览Github分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚从svn移到github。我和我的团队运行本地测试,我们提交更改并在中央开发服务器上测试。每当我们将更改推送到repos,我想自动将更改我的repos的任何分支到我的dev服务器上的文件夹。这将使我和我的团队使用我们的中央开发服务器测试和预览每个其他代码。

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.

理想情况下,我可以将子域映射到这些不同的分支目录。
I.e如果分支被称为refactor,我可以使用
检查它 http://refactor.devserver.com

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

我想这可能涉及一个钩子在我的github配置触发一个脚本在开发服务器上?也许我需要使用一个ci服务器像Hudson?

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?

编辑:我可以很容易地触发一个脚本拉动master分支 - 我需要做的是拉任何更改的分支以分离根文件夹,所以我可以通过它自己的子域轻松地测试任何分支。 (或以类似的方式自动部署和测试任何更改的分支)

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)

非常感谢。

推荐答案

这里是我自己的问题的答案的一部分...

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

我希望团队能够分叉代码,以显示在网址上,如下所示: http://branch-name.devserver.com

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

我在apache conf中设置了vhost指令,将子域映射到文件夹:

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>

我在github或本地机器上分支代码。

在开发服务器上运行这些命令

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

将克隆的repos文件夹移动到名为分支名称的文件夹,它将成为子域虚拟主机的根文件夹。

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

然后将repos从master更改为新分支

Then switch the repos from master to the new branch

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


$ b b

现在可以在 http://new-branch.devserver.com 上查看

然后在我把更改推送到github上的分支后,我在开发者服务器上将它们拖动。

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

希望拉动发生自动我可以设置一个CI服务器来监听一个git中枢钩,这将触发拉每个分支文件夹。看起来像哈德森可以这样做。

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 :


  1. 无需多次克隆资源库

  2. 使用单一命令可有效更新所有分支,我拉到只有更新的分支

  3. 对于每个分支一个体面的文件夹结构 - 所以我可以测试任何分支在一个特定的URL,而不必乱七八糟的HTTP配置每次我分支代码

  4. 可能会自动为新分支创建根文件夹,以便它们奇迹般地显示在开发服务器上

  1. Without cloning the repos many times
  2. With a single command that updates all branches efficiently or a hook that lets me pull to only the branch that was updated
  3. 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
  4. possibly automatically creating a root folder for new branches so that they would magically appear on the dev server

欢迎任何进一步的想法...

Any further thoughts welcome...

这篇关于在开发服务器上测试/预览Github分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆