start
This commit is contained in:
parent
145ba879bf
commit
ce00fa26fa
@ -17,74 +17,20 @@ $worker->onConnect = function ($connection) {
|
||||
};
|
||||
|
||||
$worker->onMessage = function (TcpConnection $connection, Request $request) {
|
||||
$work_dir = isset($_ENV['WORK_DIR']) ? $_ENV['WORK_DIR'] : null;
|
||||
$branch = isset($_ENV['BRANCH']) ? $_ENV['BRANCH'] : null;
|
||||
$git_url = isset($_ENV['GIT_URL']) ? $_ENV['GIT_URL'] : null;
|
||||
// var_dump(json_encode($request->post('repository'), JSON_UNESCAPED_UNICODE));
|
||||
if ($work_dir && $branch && $git_url) {
|
||||
$work_dir = '/www/wwwroot/fs.book.wandoubaba.com';
|
||||
$branch = 'master';
|
||||
$git_url = 'git@git.wandoubaba.com:wandoubaba/knowledge.git';
|
||||
$repository = $request->post('repository');
|
||||
if (is_array($repository)) {
|
||||
$ssh_url = isset($repository['ssh_url']) ? $repository['ssh_url'] : null;
|
||||
$clone_url = isset($repository['clone_url']) ? $repository['clone_url'] : null;
|
||||
if ($git_url === $ssh_url || $git_url === $clone_url) {
|
||||
chdir($work_dir);
|
||||
shell_exec("sh auto_build.sh");
|
||||
// shell_exec("git reset --hard FETCH_HEAD");
|
||||
|
||||
// shell_exec("yarn install");
|
||||
// shell_exec("yarn build");
|
||||
|
||||
shell_exec("sh auto_build.sh > /dev/null &");
|
||||
$connection->send("Deployment finished\n");
|
||||
$connection->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
// $connection->send($request->post());
|
||||
|
||||
// if ($work_dir && $branch) {
|
||||
// chdir($work_dir);
|
||||
// exec("git fetch origin $branch");
|
||||
// exec("git reset --hard FETCH_HEAD");
|
||||
|
||||
// exec("yarn install");
|
||||
// exec("yarn build");
|
||||
|
||||
// $connection->send("Deployment finished\n");
|
||||
// $connection->close();
|
||||
// }
|
||||
|
||||
// 设置工作目录
|
||||
// $WORK_DIR = "/www/wwwroot/fs.book.wandoubaba.com";
|
||||
|
||||
// 设置远程仓库地址
|
||||
// $REMOTE_REPO = "git@git.wandoubaba.com:wandoubaba/knowledge.git";
|
||||
|
||||
// 设置分支名称
|
||||
// $BRANCH = "master";
|
||||
|
||||
// 验证请求是否合法
|
||||
// $secret = "your-webhook-secret";
|
||||
// $signature = $_SERVER['HTTP_X_HUB_SIGNATURE'] ?? '';
|
||||
// $body = $data;
|
||||
// if (!hash_equals('sha1=' . hash_hmac('sha1', $body, $secret), $signature)) {
|
||||
// $connection->send("Invalid request\n");
|
||||
// $connection->close();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // 切换到工作目录
|
||||
// chdir($WORK_DIR);
|
||||
|
||||
// // 拉取最新代码
|
||||
// exec("git fetch origin $BRANCH");
|
||||
// exec("git reset --hard FETCH_HEAD");
|
||||
|
||||
// // 执行相关命令
|
||||
// exec("yarn install");
|
||||
// exec("yarn build");
|
||||
|
||||
// $connection->send("Deployment finished\n");
|
||||
// $connection->close();
|
||||
};
|
||||
|
||||
// 运行worker
|
||||
|
Loading…
Reference in New Issue
Block a user