服务安装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 ?>

服务器对接码云webhooks

填入域名,点击提交

 

相关文章:

  • 2021-11-04
  • 2021-11-29
  • 2021-10-11
  • 2021-04-05
  • 2021-08-21
  • 2022-01-13
  • 2021-08-15
  • 2021-07-19
猜你喜欢
  • 2021-09-25
  • 2021-10-23
  • 2021-07-14
  • 2021-11-10
  • 2021-12-16
  • 2021-12-01
  • 2021-11-10
相关资源
相似解决方案