giee 通过webhooks部署代码到服务器

#!/bin/bash

cd /www/wwwroot/xxx.xxxxx.com
git fetch --all
git reset --hard origin/master
git pull https://username:[email protected]/xxx/xxx.git master
namespace app\index\controller;

use think\facade\Request;
class Hooks
{
    public function hook(){
        $request = Request::instance();
        $params = $request->param();

        $pwd = $params['password'];

        if($pwd == '111112323123'){
            $command = '/www/wwwroot/xxx.xxxxx.com/update.sh';
            chown($command,'www');
            chmod($command,0755);
            exec($command,$output);
            return json(['code'=>200,'msg'=>'远程更新成功','data'=>$output]);
        }else{
            return json(['code'=>300,'msg'=>'更新失败','data'=>[]]);
        }
    }
}

猜你喜欢

转载自blog.csdn.net/u013373006/article/details/108935675