【服务器】

1、切换到项目目录下 cd /data/www/test

2、进入 .git 文件夹 cd .git 然后 ll

3、授权

chmod -R 777 FETCH_HEAD

chmod -R 777 ./objects

chmod -R 777 ./refs

chmod -R 777 ./logs

【代码】

在public下建一个文件test.php,然后使用网址 www.test.com/test.php能够访问(外网能访问)

写上:

<?php
/**
 * 自动更新钩子
 **/
//本地路径
$local = '/data/wwwroot/test';  //需要修改为自己服务器上项目的路径的
//密码
$password = 'test123'; //webhooks中设置的密码
//获取请求参数
$request = file_get_contents('php://input');
if (empty($request)) {
    die('request is empty');
}
//验证密码是否正确
$data = json_decode($request, true);
if ($data['password'] != $password) {
    die('password is error');
}
//仓库地址
$remote = 'https://用户名:密码@gitee.com/xxxxxxx/xxxx.git'; //自己git仓库,加上用户名密码防止没有权限
echo shell_exec("cd {$local} && git pull {$remote} 2>&1");
die('done ' . date('Y-m-d H:i:s', time()));
【GITEE】
进入具体的项目中,点管理,然后点击webhooks添加钩子

gitee利用WebHooks自动部署到服务器,跟着步骤走就行

 

相关文章:

  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-06
  • 2022-12-23
  • 2021-08-02
  • 2022-01-04
  • 2022-12-23
  • 2021-07-15
  • 2021-12-18
相关资源
相似解决方案