php git hook

2016-11-29 • PHPNo Comments

//网站目录
$www_file='/www/web/wwwroot/default/wifi';
$client_ip = $_SERVER['REMOTE_ADDR'];

$fs = fopen($www_file.'/hooks.log', 'a');
fwrite($fs, '================ Update Start ==============='.PHP_EOL.PHP_EOL);
fwrite($fs, 'Request on ['.date("Y-m-d H:i:s").'] from ['.$client_ip.']'.PHP_EOL);


$output = exec("cd $www_file && git pull https://xx%40163.com:oneday.152@gitee.com/xx/xx.git master   >> hooks.log  2>&1");

fwrite($fs, 'Info:'. $output.PHP_EOL);
fwrite($fs,PHP_EOL. '================ Update End ==============='.PHP_EOL.PHP_EOL);
  
$fs and fclose($fs);

粤公网安备 44011102000950号