start done
This commit is contained in:
parent
d46721a5e3
commit
315d7f9193
@ -1,2 +1,3 @@
|
|||||||
WORK_DIR = "/www/wwwroot/fs.book.wandoubaba.com"
|
WORK_DIR = "/www/wwwroot/fs.book.wandoubaba.com"
|
||||||
BRANCH = "master"
|
BRANCH = "master"
|
||||||
|
GIT_URL = "git@git.wandoubaba.com:wandoubaba/knowledge.git"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Workerman\Worker;
|
use Workerman\Worker;
|
||||||
use Workerman\Connection\TcpConnection;
|
use Workerman\Connection\TcpConnection;
|
||||||
use Workerman\Protocols\Http\Request;
|
use Workerman\Protocols\Http\Request;
|
||||||
@ -15,24 +16,42 @@ $worker->onConnect = function ($connection) {
|
|||||||
echo "New connection\n";
|
echo "New connection\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
$worker->onMessage = function(TcpConnection $connection, Request $request)
|
$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(json_encode($request->post('repository'), JSON_UNESCAPED_UNICODE));
|
$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) {
|
||||||
|
$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("git fetch origin $branch");
|
||||||
|
shell_exec("git reset --hard FETCH_HEAD");
|
||||||
|
|
||||||
|
shell_exec("yarn install");
|
||||||
|
shell_exec("yarn build");
|
||||||
|
|
||||||
|
$connection->send("Deployment finished\n");
|
||||||
|
$connection->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// $connection->send($request->post());
|
// $connection->send($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();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 设置工作目录
|
// 设置工作目录
|
||||||
// $WORK_DIR = "/www/wwwroot/fs.book.wandoubaba.com";
|
// $WORK_DIR = "/www/wwwroot/fs.book.wandoubaba.com";
|
||||||
|
Loading…
Reference in New Issue
Block a user