1 Star 1 Fork 0

fwz / gitee钩子

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
test.php 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
fwz 提交于 2020-08-30 16:17 . 测试
<?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文件中
}
PHP
1
https://gitee.com/fengzi6/gitee-hook.git
git@gitee.com:fengzi6/gitee-hook.git
fengzi6
gitee-hook
gitee钩子
master

搜索帮助