使用Github的webhooks进行代码的自动化同步
代码地址
随着GitHub私有仓库的免费,我们可以使用GitHub做很多事情。
我们使用GitHub的webhooks功能,可以将本地的代码自动同步到我们服务器上,自动的更新我们的代码。
setting > webhooks
Webhooks allow external services to be notified when certain events happen. When the specified events happen, we’ll send a POST request to each of the URLs you provide. -来自GitHub
Webhooks允许在发生特定事件时通知外部服务。 当指定的事件发生时,我们将向您提供的每个URL发送POST请求。通过这个post请求,我们就能实现自动拉取仓库中的代码,更新到本地,最终实现自动化更新
在自动同步端,我们首先将仓库clone到本地,然后通过编写sh脚本实现自动拉取代码,同步。
WEB_PATH='../test' //仓库位置
WEB_USER='root'
WEB_USERGROUP='root'
echo "Start deployment"
cd