[英]Testing/previewing Github branches on a dev server
I've just moved from svn to github. 我刚从svn转到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.
每当我们将更改推送到repos时,我想自动将更改到我的repos的任何分支到我的开发服务器上的文件夹中。 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
即如果该分支被称为“重构”,我可以使用http://refactor.devserver.com进行检查
I guess this might involve a hook in my github configuration that triggers a script on the dev server? 我想这可能涉及我的github配置中的一个钩子,它在dev服务器上触发了一个脚本? Perhaps i need to use a ci server like Hudson?
也许我需要使用像Hudson这样的ci服务器?
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 我希望团队能够分叉代码并立即在这样的URL上显示它: http : //branch-name.devserver.com
I set up vhost directives in apache conf to map sub domains to folders : 我在apache conf中设置了vhost指令,将子域映射到文件夹:
<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. 我在github或我的本地机器上分支代码。
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. 将克隆的repos文件夹移动到名为分支名称的文件夹,以使其成为子域虚拟主机的根文件夹。
mv repos-name new-branch
Then switch the repos from master to the new branch 然后将repos从master切换到新分支
cd /var/www/devserver/new-branch
git checkout new-branch
It's now available on http://new-branch.devserver.com 它现在可以在http://new-branch.devserver.com上找到
Then after I've pushed changes to the branch on github - I pull them on the dev server 然后在我将更改推送到github上的分支后 - 我将它们放在开发服务器上
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. 现在 - 如果我想让拉动自动发生,我可以设置一个CI服务器来监听一个git hub钩子,它会触发每个分支文件夹的拉动。 Looks like Hudson could do this.
看起来Hudson可以做到这一点。
I'd hoped to find a smarter way to do this : 我希望找到一个更聪明的方法来做到这一点:
Any further thoughts welcome... 欢迎进一步的想法...
It can certainly be done using Hudson if you have some automatic deploy procedure defined. 如果您定义了一些自动部署过程,它肯定可以使用Hudson完成。 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.
事实上,我在大约一年前做了类似的设置 - 如果改变被推入大师Hudson进行单元测试并且如果成功部署到舞台上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.