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

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

问题描述

我刚刚从 svn 搬到了 github.我和我的团队运行本地测试,我们在中央开发服务器上提交更改和测试.每当我们将更改推送到存储库时,我都希望自动将存储库的任何分支的更改拉到我的开发服务器上的文件夹中.这将使我和我的团队能够使用我们的中央开发服务器测试和预览彼此的代码.

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.

理想情况下,我可以将子域映射到这些不同的分支目录.IE.如果分支被称为重构",我可能会使用它来检查它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 配置中的一个钩子,它会触发开发服务器上的脚本?也许我需要使用像 Hudson 这样的 ci 服务器?

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)

非常感谢.

推荐答案

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

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

现在可以在 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 hub 钩子,该钩子会触发每个分支文件夹中的拉动.看起来哈德森可以做到这一点.

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. 可能会自动为新分支创建一个根文件夹,以便它们神奇地出现在开发服务器上

欢迎大家多多交流……

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

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