autopull

项目部署在github上(不会部署可以参考我前面的文章),代码在自己的服务器上面,本地开发,本地开发好先将代码push到github上面,在登录服务器同步github上面的代码。很烦=。=
这里可以使用github自带的“钩子”功能来帮我们自动pull代码。
进入你github上的项目中,按如下图片操作来添加webhook
B295871F-7DC5-473F-93B7-5E87F2C4BE09
6C68606D-72B4-44B2-A5D6-B763A12B4FBF
github在每次收到push内容时会调用你填写的webhook地址。所以自动pull的原理就是
你push代码到github -> github立即调用webhook -> webhook地址对应的服务器脚本来执行pull命令
关于自动pull的脚本网上有好多(网上有的提供了安全性检查),我自己随便写了一个

$fp=fopen(“./autopulllog.txt”,’a’);
exec(“cd /data/web/CodeIgniter”);//进入目录
exec(“git pull origin master”);//进行git拉取,前提是使用了ssh
fwrite($fp,”※”.date(‘Y-m-d H:i:s’).”\tautopull\t\n”);//进行记录

对了,有些人的php会默认禁用掉exec这个风险函数,如果提示exec函数找不到,需要去php.ini中开启
如果成功了webhook页面可以看到的
DB4C1041-1A32-489A-BB03-E2C4537D9AFF

  5 comments for “autopull

  1. 2016-08-17 at 22:21

    I’ve been through this!

  2. 2016-08-18 at 19:34

    Do not rush me.

  3. 2016-08-19 at 04:38

    I respect your work.

  4. 2016-08-19 at 13:36

    I was thinking if after work we could grab a cup of coffee

  5. 2016-08-19 at 17:58

    You’re very professional.

fifa 17 ps4 coins进行回复 取消回复

邮箱地址不会被公开。