设为首页 加入收藏

TOP

服务器对接码云webhooks
2019-08-24 00:02:50 】 浏览:44
Tags:服务器 对接 webhooks

服务安装git

 

php代码(外网必须可以访问)

 1 <?php
 2 //本地路径滚adminasdfdasfasdf
 3 $file = "/wwwroot/webhooksLog.txt";
 4 $_File = fopen($file, "a+");
 5 $local = '/wwwroot/test';
 6 //仓库地址
 7 $remote = '远程仓库地址';
 8  
 9 //密码
10 $password = '123456';
11  
12 //获取请求参数
13 $request = file_get_contents('php://input');
14 if (empty($request)) {
15   die('请求参数为空');
16 }
17  
18 //验证密码是否正确
19 $data = json_decode($request, true);
20 if ($data['password'] != $password) {
21   die('密码错误');
22 }
23 fwrite($_File, "************************************************\r\n");
24 fwrite($_File, "推送人Name: ");
25 fwrite($_File, $data["pusher"]["name"] . "\r\n");
26 fwrite($_File, "推送人Email: ");
27 fwrite($_File, $data["pusher"]["email"] . "\r\n");
28 fwrite($_File, "推送人UserName: ");
29 fwrite($_File, $data["pusher"]["username"] . "\r\n");
30 fwrite($_File, "推送人备注: ");
31 fwrite($_File, $data["head_commit"]["message"] . "\r\n");
32 fwrite($_File, "推送项目: ");
33 fwrite($_File, $data["repository"]["full_name"] . "\r\n");
34 fwrite($_File, "推送分支: ");
35 fwrite($_File, $data["ref"] . "\r\n");
36 fwrite($_File, "推送日期: ");
37 fwrite($_File, $data["head_commit"]["timestamp"] . "\r\n");
38 fwrite($_File, "************************************************\r\n");
39 fclose($_File);
40 //return;
41 //echo shell_exec("cd {$local} && git pull {$remote} 2>&1");
42 system('cd '.$local.' && "C:/Program Files/Git/cmd/git.exe" pull '.$remote.' 2>&1', $out);
43 echo $out;
44 die('done' . date('Y-m-d H:i:s'));
45 ?>

填入域名,点击提交

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Laravel 系列入门教程(二)【最.. 下一篇Laravel 系列入门教程(四)【最..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目