add git source: HIT
parent
459b23b284
commit
9139fbda53
|
@ -375,34 +375,33 @@ function setConfigResponse($response)
|
||||||
return json_decode($response, true);
|
return json_decode($response, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function OnekeyUpate($auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
function OnekeyUpate($GitSource = 'Github', $auth = 'qkqpttgf', $project = 'OneManager-php', $branch = 'master')
|
||||||
{
|
{
|
||||||
$tmppath = '/tmp';
|
$tmppath = '/tmp';
|
||||||
|
|
||||||
|
if ($GitSource=='Github') {
|
||||||
// 从github下载对应tar.gz,并解压
|
// 从github下载对应tar.gz,并解压
|
||||||
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
$url = 'https://github.com/' . $auth . '/' . $project . '/tarball/' . urlencode($branch) . '/';
|
||||||
|
} elseif ($GitSource=='HITGitlab') {
|
||||||
|
$url = 'https://git.hit.edu.cn/' . $auth . '/' . $project . '/-/archive/' . urlencode($branch) . '/' . $project . '-' . urlencode($branch) . '.tar.gz';
|
||||||
|
} else return json_encode(['error'=>['code'=>'Git Source input Error!']]);
|
||||||
|
|
||||||
$tarfile = $tmppath . '/github.tar.gz';
|
$tarfile = $tmppath . '/github.tar.gz';
|
||||||
$githubfile = file_get_contents($url);
|
file_put_contents($tarfile, file_get_contents($url));
|
||||||
if (!$githubfile) return '{"error":{"message":"fail to download from github"}}';
|
$phar = new PharData($tarfile);
|
||||||
file_put_contents($tarfile, $githubfile);
|
$html = $phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
|
||||||
$phar = new PharData($tarfile); // need php5.3, 7, 8
|
|
||||||
$phar->extractTo($tmppath, null, true);//路径 要解压的文件 是否覆盖
|
|
||||||
unlink($tarfile);
|
unlink($tarfile);
|
||||||
|
|
||||||
$outPath = '';
|
// 获取解压出的目录名
|
||||||
$tmp = scandir($tmppath);
|
$outPath = findIndexPath($tmppath);
|
||||||
$name = $auth . '-' . $project;
|
|
||||||
mkdir($tmppath . "/" . $name, 0777);
|
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
|
||||||
foreach ($tmp as $f) {
|
$name = $project . 'CODE';
|
||||||
if ( substr($f, 0, strlen($name)) == $name) {
|
mkdir($tmppath . "/" . $name, 0777, 1);
|
||||||
rename($tmppath . '/' . $f, $tmppath . "/" . $name . '/api');
|
rename($outPath, $tmppath . "/" . $name . '/api');
|
||||||
$outPath = $tmppath . "/" . $name;
|
$outPath = $tmppath . "/" . $name;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//echo $outPath . "<br>";
|
//echo $outPath . "<br>";
|
||||||
//error_log1($outPath);
|
//error_log1($outPath);
|
||||||
if ($outPath=='') return '{"error":{"message":"no outpath"}}';
|
|
||||||
|
|
||||||
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath);
|
return VercelUpdate(getConfig('HerokuappId'), getConfig('APIKey'), $outPath);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue