Skip to content

Instantly share code, notes, and snippets.

@GeekGhc
Last active August 17, 2017 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeekGhc/43b0927de6016578f741bc6beab3023a to your computer and use it in GitHub Desktop.
Save GeekGhc/43b0927de6016578f741bc6beab3023a to your computer and use it in GitHub Desktop.
<?php
error_reporting(1);
$target = '/data/www/ISpace'; // 生产环境web目录
$token = 'ispace'; //GitLab 添加的token
$wwwUser = 'root';
$wwwGroup = 'root';
if (empty($_SERVER['HTTP_X_GITLAB_TOKEN']) || $_SERVER['HTTP_X_GITLAB_TOKEN'] !== $token) {
exit('error request');
}
/*if($_SERVER['HTTP_X_GITLAB_TOKEN'] == $token){
echo "校验成功";
}*/
//$repo = $json['repository']['name'];
// $cmds = array(
// "cd $target && git pull",
// "chown -R {$wwwUser}:{$wwwGroup} $target/",
// );
// foreach ($cmds as $cmd) {
// shell_exec($cmd);
// }
chdir($target);
$cmd = "sudo -Hu root git pull";
shell_exec($cmd);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment