ensure to load buildconfig from selected git sha

This commit is contained in:
andreas 2023-10-05 19:37:46 +02:00
parent 12288edbf8
commit 4af9434b29
4 changed files with 28 additions and 8 deletions

View File

@ -226,7 +226,10 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
downloadConfig: downloadConfig
};
const loadConfig=async (url)=>{
let config=await fetch(url).then((r)=>r.text());
let config=await fetch(url).then((r)=>{
if (!r.ok) throw new Error("unable to fetch: "+r.statusText);
return r.text()
});
let parsed=yamlLoad(config);
return parsed;
}
@ -423,9 +426,6 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
fetchStatus(true);
setRunning(true);
}
structure=await loadConfig("build.yaml");
buildSelectors(ROOT_PATH,structure.config.children,true);
if (! running) findPipeline();
let gitParam={user:GITUSER,repo:GITREPO};
let branch=getParam('branch');
if (branch){
@ -479,6 +479,19 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
else{
setValue('gitSha',gitSha);
}
if (gitSha !== undefined){
let url=buildUrl(GITAPI,Object.assign({},gitParam,{sha:gitSha,proxy:'webinstall/build.yaml'}));
try{
structure=await loadConfig(url);
}catch (e){
alert("unable to load config for selected release:\n "+e+"\n falling back to default");
}
}
if (! structure){
structure=await loadConfig("build.yaml");
}
buildSelectors(ROOT_PATH,structure.config.children,true);
if (! running) findPipeline();
updateStart();
}
})();

View File

@ -15,12 +15,12 @@ function fillUserAndRepo($vars=null,$source=null){
}
foreach (array('user','repo') as $n){
if (! isset($source[$n])){
die("missing parameter $n");
throw new Exception("missing parameter $n");
}
$v=$source[$n];
$av=$allowed[$n];
if (! in_array($v,$av)){
die("value $v for $n not allowed");
throw new Exception("value $v for $n not allowed");
}
$vars[$n]=$v;
}

View File

@ -39,7 +39,7 @@ function addVars(&$vars,$names,$defaults=null){
foreach ($names as $n){
$v=null;
if (! isset($_REQUEST[$n])){
if ($defaults == null || ! isset($defaults[$n])) die("missing parameter $n");
if ($defaults == null || ! isset($defaults[$n])) throw new Exception("missing parameter $n");
$v=$defaults[$n];
}
else{

View File

@ -7,6 +7,7 @@ $branchsha=API_BASE."/git/refs/heads/#branch#";
$tagsha=API_BASE."/git/refs/tags/#tag#";
$download = "https://github.com/#user#/#repo#/releases/download/#dlVersion#/#dlName#";
$manifest = "?dlName=#mName#&dlVersion=#mVersion#&user=#user#&repo=#repo#";
$proxurl="https://raw.githubusercontent.com/#user#/#repo#/#sha#/#proxy#";
try {
if (isset($_REQUEST['api'])) {
$vars = fillUserAndRepo();
@ -50,11 +51,17 @@ try {
}
}
if (!$targetUrl)
die("unable to find $targetBase $mode\n");
throw new Exception("unable to find $targetBase $mode\n");
#echo("download for $targetBase=$targetUrl\n");
proxy($targetUrl);
exit(0);
}
if (isset($_REQUEST['proxy'])){
$vars = fillUserAndRepo();
$vars = addVars($vars, array('sha', 'proxy'));
proxy(replaceVars($proxurl, $vars));
exit(0);
}
} catch (HTTPErrorException $h) {
header($_SERVER['SERVER_PROTOCOL'] . " " . $h->code . " " . $h->getMessage());
die($h->getMessage());