<?php
if (!isset($_SERVER['HTTP_X_GITLAB_TOKEN']) || !isset($_SERVER['REMOTE_ADDR'])) {
exit('403');
}
//检测token
$token = '**************';
if ($_SERVER['HTTP_X_GITLAB_TOKEN'] != $token) {
exit('token is invaild');
}
$whiteIp = ['127.0.0.1'];
//检测ip
$ip = $_SERVER['REMOTE_ADDR'];
if (!in_array($ip, $whiteIp)) {
exit('ip is invaild');
}
$config = [
'分支名称' => '站点路径',
];
//获取参数
$post = (array)json_decode(file_get_contents('php://input'), true);
$eventName = !empty($post['event_name']) ? $post['event_name'] : '';
$currentRef = '';//当前操作分支
switch (strtolower($eventName)) {
case 'push' :
$ref = !empty($post['ref']) ? $post['ref'] : '';
git钩子自动更新代码
最新推荐文章于 2024-03-06 16:45:31 发布