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