GitHub - 使用远程服务器设置自动部署 [英] GitHub - setup auto deployment with remote server
问题描述
目前,我的制作网站托管在Azure上。我使用git并将所有提交都推送给GitHub。使用 git hooks
的魔力,当有人将某个分支推送到GitHub时,Azure可以从GitHub中获取。
如何使用托管的本地临时服务器复制此内容?换句话说,我该如何在GitHub上设置回购协议,并且当我推送到它时,通过git挂钩发送信号,请求或者什么 - 您可以自动拉动我的内部部署服务器?
我知道Git不是一个部署软件,但是如果我必须在我的服务器上编写一个机制来实现这个目标,我想知道从哪里开始。如果它有帮助,我们使用Microsoft技术,所以我们在Windows Server上运行我们的登台服务器,而我们的产品是在Azure上。
我知道我需要在我的服务器上使用回调URL,然后执行所需的任何操作。我想知道人们用什么方法来完成此操作。例如:在我的回调url上,我将如何调用脚本来运行pull / fetch / clone bash命令。或其他方法。
如果您需要更多信息,请随时询问。
扩展我的评论,
-
您需要定义/创建将需要是在您的结束///stackoverflow.com/questions/23347056/what-is-a-callback-url-in-relation-to-an-api\"> callback url 公共访问。
-
github
会通过git hook
,只要对有问题的分支进行
推送即可。 -
钩子,如果需要的话。
> -
现在您的服务器应该启动执行
pull / clone的部署任务。
关于这个部署任务,有很多方法可以做到这一点,更细的细节将会有所不同取决于ng
$ b
一种方法是引入一个持续集成工具,如詹金斯在你的堆栈中,你也可以用它来在不同的环境中进行常规和测试构建。
另外一种方法是执行一个简单的bash脚本,其中 cd $ REPO_DIR&& git pull origin branchname&&服务apache2等重新启动
。 Currently, my production website is hosted on Azure. I use git and push all my commits to GitHub. With the magic of git hooks
Azure has the ability to pull from GitHub when someone pushes a certain branch to GitHub.
How can I replicate this with my own staging server hosted on-premise? In other words, how can I set a repo on GitHub, and when I push to it, through git hooks send a signal, request or what-have-you to perform an automatic pull on my on-premise server?
I know Git is not a deployment software, but if I have to write a mechanism on my on-prmise server to make this happen I would like to know where to start. If it's helpful, we use Microsoft technology, so we are running our staging server on Windows Server, while our production is on Azure.
I understand that I'll need to use callback url on my server to then perform whatever is needed.I would like to know what methods people use to accomplish this. e.g.: on my call back url, how would I call a script to run a pull/fetch/clone bash command. or other method.
If you need more information, feel free to ask.
Expanding upon my comment,
You would need to define/create a callback url on your end, which will need to be publicly accessible.
github
would make a hit to this url via agit hook
whenever a push is made to the branch in question.You can add authentication for the hit in the hook, if needed.
This call will inform your server that a push has been made to the certain branch on github.
Now your server should start a deployment task which does the pull/clone.
Regarding this deployment task, there are many ways to do this, and the finer details will vary depending on how you do it.
One way would be to introduce a Continuous Integration tool like Jenkins in your stack, which you could also use for regular and test builds in different environments.
Another way could be to execute a simple bash script which does cd $REPO_DIR && git pull origin branchname && service apache2 etc restart
.
这篇关于GitHub - 使用远程服务器设置自动部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!