Merge branch 'main' of https://gitea.zachem.info/developer/lk.zachem.info
This commit is contained in:
commit
f8a82ed2c8
31
public/pull.php
Normal file
31
public/pull.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?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("wrong signature");
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = json_decode($payload, true);
|
||||||
|
|
||||||
|
if (json_last_error() !== JSON_ERROR_NONE)
|
||||||
|
{
|
||||||
|
error_log('FAILED - json decode - '. json_last_error());
|
||||||
|
exit(json_last_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
if($json['total_commits'] > 0)
|
||||||
|
{
|
||||||
|
$result = shell_exec("cd /var/www/lk && git reset --hard HEAD && git pull");
|
||||||
|
echo "<p>$result</p>";
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user