добавлен обработчик вебхука гитлаба
This commit is contained in:
parent
642236f442
commit
f66611ce18
28
public/pull.php
Normal file
28
public/pull.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$key = "developer@zachem.info";
|
||||||
|
$payload = trim(file_get_contents("php://input"));
|
||||||
|
|
||||||
|
$hash = hash_hmac('sha256', $payload, $key, false);
|
||||||
|
|
||||||
|
$signature = $_SERVER['HTTP_X_GITEA_SIGNATURE']?? '';
|
||||||
|
|
||||||
|
// check payload signature against header signature
|
||||||
|
if ($hash !== $signature)
|
||||||
|
{
|
||||||
|
error_log('FAILED - payload signature mismatch');
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = json_decode($payload, true);
|
||||||
|
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE)
|
||||||
|
{
|
||||||
|
error_log('FAILED - json decode - '. json_last_error());
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strcmp($json['object_kind'], 'push') == 0)
|
||||||
|
{
|
||||||
|
shell_exec("cd /var/www/lk && git reset --hard HEAD && git pull");
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user