您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

关于github使用webhook部署代码的问题?

2025/1/14 13:23:25发布9次查看
使用php处理github发送过来的请求,测试正常。在调用脚本或使用exec()执行命令总是不能成功。
// 判断签名是否匹配if ($hash === $payloadhash) { // 调用shell // file_put_contents('/var/www/niucunhui.io/auto/test.txt', '程序走到这里了'); exec('cd /var/www/niucunhui.io/auto/ && git pull');}

file_put_contents可以写入内容,证明签名是匹配成功的。在服务器单独执行脚本,也是可以pull代码。
脚本如下:
#!/bin/bashweb_path='/var/www/niucunhui.io/sql-optimize-referance/'web_user='www'web_usergroup='www'echo start deploymentcd $web_pathecho pulling source code...git reset --hard origin/mastergit clean -fgit pullgit checkout masterecho changing permissions...chown -r $web_user:$web_usergroup $web_pathecho finished.

单独写一个php程序 exec()命令也是可以执行的。
请问,还有可能是那里的问题?
服务器版本 centos 6.5
php版本 5.6.15
回复内容: 使用php处理github发送过来的请求,测试正常。在调用脚本或使用exec()执行命令总是不能成功。
// 判断签名是否匹配if ($hash === $payloadhash) { // 调用shell // file_put_contents('/var/www/niucunhui.io/auto/test.txt', '程序走到这里了'); exec('cd /var/www/niucunhui.io/auto/ && git pull');}

file_put_contents可以写入内容,证明签名是匹配成功的。在服务器单独执行脚本,也是可以pull代码。
脚本如下:
#!/bin/bashweb_path='/var/www/niucunhui.io/sql-optimize-referance/'web_user='www'web_usergroup='www'echo start deploymentcd $web_pathecho pulling source code...git reset --hard origin/mastergit clean -fgit pullgit checkout masterecho changing permissions...chown -r $web_user:$web_usergroup $web_pathecho finished.

单独写一个php程序 exec()命令也是可以执行的。
请问,还有可能是那里的问题?
服务器版本 centos 6.5
php版本 5.6.15
https://zhuzhenyu.org/2016/01/03/php-github-php/
git命令需要写全路径
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product