代码拉取完成,页面将自动刷新
<?php
$requestBody = file_get_contents("php://input");
if (empty($requestBody)) {
die('send fail');
}
$content = json_decode($requestBody, true);
if ($content['ref'] == 'refs/heads/master' && $content['total_commits_count'] > 0 && $content['password'] == 'fwzi') {
exec("cd D:\wamp64\gitee && git pull origin master 2<&1", $output, $return);
$res_log = PHP_EOL . '----------------------------------------------------------------------------------------------------' . PHP_EOL;
$res_log .= $content['user_name'] . ' 在' . date('Y-m-d H:i:s') . '向' . $content['repository']['name'] . '项目的' . $content['ref'] . '分支push了' . $content['total_commits_count'] . '个commit:';
$res_log .= PHP_EOL . "pull start --------" . PHP_EOL;
$res_log .= '$output:' . var_export($output, true) . PHP_EOL . '$return:' . var_export($return, true) . PHP_EOL;
$res_log .= PHP_EOL . "pull end --------" . PHP_EOL;
//$res_log .= var_export($requestBody, true);
file_put_contents("./git_webhook.log", $res_log, FILE_APPEND);//写入日志到log文件中
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。