Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$target = __DIR__ . '/../'; // 生产环境web目录
$token = '您在coding填写的hook令牌';
$wwwUser = 'apache';
$wwwGroup = 'apache';
$json = json_decode(file_get_contents('php://input'), true);
if (empty($json['token']) || $json['token'] !== $token) {
exit('error request');
$repo = $json['repository']['name'];
$dir = __DIR__ . '/repos/' . $repo;
$cmds = array(
"cd $dir && git pull",
"rm -rf $target/* && cp -r $dir/* $target/",
"chown -R {$wwwUser}:{$wwwGroup} $target/",
foreach ($cmds as $cmd) {
Copy link

laojiu commented Mar 26, 2016

我的系统是centos + nginx 为什么 web 访问的时候 shell_exec("whoami"); 返回的是apache用户 ? 我按照你的方式 使用了www 用户 不行哦

Copy link

costa92 commented Feb 16, 2017

shell_exec('git pull') 无效,是什么原因呢?

Copy link

youmikuang commented Jun 26, 2017


Copy link

consatan commented Jan 17, 2019

rm -rf $target/* && cp -r $dir/* $target/

这命令不合适吧,如果 $target 里有 uploads 目录,或者文件比较多 rm 后等待 cp 时间较久,那不就 gg 了?
为啥不用 rsync ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment