如何在git push(GitHub和node.js)之后自动部署我的应用程序? [英] How can I automatically deploy my app after a git push ( GitHub and node.js)?
本文介绍了如何在git push(GitHub和node.js)之后自动部署我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序(node.js)部署在VPS(linux)上。我使用git hub作为存储库。如何在git push上自动部署应用程序?
I have my application (node.js) deployed on a VPS (linux). I'm using git hub as a repository. How can I deploy the application automatically, on git push ?
推荐答案
PHP中的示例:
导航到github到你的github仓库添加点击Admin
Navigate to github into your github repository add click "Admin"
点击标签'Service Hooks'=>'WebHook URL
click tab 'Service Hooks' => 'WebHook URLs'
并添加
http://your-domain-name/git_test.php
然后创建git_test.php
then create git_test.php
<?php
try
{
$payload = json_decode($_REQUEST['payload']);
}
catch(Exception $e)
{
exit(0);
}
//log the request
file_put_contents('logs/github.txt', print_r($payload, TRUE), FILE_APPEND);
if ($payload->ref === 'refs/heads/master')
{
// path to your site deployment script
exec('./build.sh');
}
在build.sh中,您需要通常的命令来检索您的网站来自github
In the build.sh you will need to put usual commands to retrieve your site from github
这篇关于如何在git push(GitHub和node.js)之后自动部署我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文