start.php

This commit is contained in:
wandoubaba 2023-07-04 13:49:23 +08:00
parent 8f71e14a27
commit 96295847cd

View File

@ -15,21 +15,22 @@ $worker->onConnect = function ($connection) {
echo "New connection\n"; echo "New connection\n";
}; };
$worker->onMessage = function(TcpConnection $connection, Request $data) $worker->onMessage = function(TcpConnection $connection, Request $request)
{ {
$work_dir = isset($_ENV['WORK_DIR']) ? $_ENV['WORK_DIR'] : null; $work_dir = isset($_ENV['WORK_DIR']) ? $_ENV['WORK_DIR'] : null;
$branch = isset($_ENV['BRANCH']) ? $_ENV['BRANCH'] : null; $branch = isset($_ENV['BRANCH']) ? $_ENV['BRANCH'] : null;
var_dump($request->post());
if ($work_dir && $branch) { if ($work_dir && $branch) {
chdir($work_dir); // chdir($work_dir);
exec("git fetch origin $branch"); // exec("git fetch origin $branch");
exec("git reset --hard FETCH_HEAD"); // exec("git reset --hard FETCH_HEAD");
exec("yarn install"); // exec("yarn install");
exec("yarn build"); // exec("yarn build");
$connection->send("Deployment finished\n"); // $connection->send("Deployment finished\n");
$connection->close(); // $connection->close();
} }
// 设置工作目录 // 设置工作目录