Why is the webhooks of github not actually implemented?

problem description

I referred to

https://blog.kinggui.com/arch...
https://www.jianshu.com/p/50e...

these two articles attempt to publish locally written gitbook e-books to Aliyun via github

my webhook.php file:

<?php
//
$local = "/alidata1/www/web/www.example.me/";
//github
$remote = "https://github.com/example/example.git";
//githubgitee
//github
$secret = "password";
//
$request = file_get_contents("php://input");
if (empty($request)) {
    die("request is empty");
}
//http 
$headers = getHeaders();
//github
$hubSignature = $headers["X-Hub-Signature"];
list($algo, $hash) = explode("=", $hubSignature, 2);
// 
$payloadHash = hash_hmac($algo, $request, $secret);
// 
if ($hash != $payloadHash) {
    die("secret is error");
}
// echo shell_exec("cd {$local} && /usr/bin/git pull {$remote} 2>&1");
// /root/github_synch.sh 
echo shell_exec("/root/github_synch.sh");
die("done " . date("Y-m-d H:i:s", time()));
/**
 * @todo 
*/
function getHeaders()
{
    $headers = array();
    //Apachegetallheaders
    if (!function_exists("getallheaders")) {
        foreach ($_SERVER as $name => $value) {
            if (substr($name, 0, 5) == "HTTP_") {
                $headers[str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($name, 5)))))] = $value;
            }
        }
    } else {
        $headers = getallheaders();
    }
    return $headers;
}

the warehouse path of the e-book on the server is / alidata1/www/web/www.example.me/ above.
gitbook will be in the _ book directory when compiling the book.
so I set the URL of the hook file to www.example.me/webhook.php
of course, the webhook.php file has been put in / alidata1/www/web/www.example.me/_book/, the group of webhook.php is www.www, and the permission is 755.

github_synch.sh (root.root 755) the contents of this file:

-sharp!/bin/bash

cd /alidata1/www/web/www.example.com
git pull origin master
chown -R www.www /alidata1/www/web/www.example.com
chmod +x /alidata1/www/web/www.example.com/_book/webhook.php

then configure webhook on the github website. After all the configuration, look at the test information and find that it is a pair of ticks. I felt that there was nothing wrong with the configuration, so I actually tested it again. A temporary file was added to the local warehouse and submitted locally to github. I looked at the webhook information and found that the file was not actually created. But when I returned to the server, I found that it was not actually created. Click response:

php.iniphp-fpm.
webhook:

and think that this script should not be executed, or the permission problem, so change / etc/sudoers to add such a line

 www  ALL=(root) NOPASSWD:/usr/bin/git

confirm that the git path is correct through which.
the test results still show that the effect has not been achieved. Resopnse is normal.
so, what exactly should I do?

Jul.14,2022

finally found the answer. It's still a question of permission configuration. Does php-fpm execute shell_exec ("/ root/github_synch.sh") as www

and my configuration in the / etc/sudoers file is incorrect. The correct thing should be:

www ALL=(ALL) NOPASSWD:/usr/bin/git
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e85264-d31.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e85264-d31.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?