correctly set tag filter for jobs, compute git sha before starting a job
This commit is contained in:
parent
9ddcbdc34a
commit
faa946c8dc
|
@ -1,10 +1,6 @@
|
||||||
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
||||||
# See: https://circleci.com/docs/configuration-reference
|
# See: https://circleci.com/docs/configuration-reference
|
||||||
version: 2.1
|
version: 2.1
|
||||||
# set the filter to allow a build for any sha tag
|
|
||||||
filters:
|
|
||||||
tags:
|
|
||||||
only: /.*/
|
|
||||||
parameters:
|
parameters:
|
||||||
run_build:
|
run_build:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
@ -76,3 +72,7 @@ workflows:
|
||||||
when: << pipeline.parameters.run_build >>
|
when: << pipeline.parameters.run_build >>
|
||||||
jobs:
|
jobs:
|
||||||
- pio-build
|
- pio-build
|
||||||
|
# set the filter to allow a build for any sha tag
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /.*/
|
||||||
|
|
|
@ -10,6 +10,14 @@
|
||||||
<div class="configui container">
|
<div class="configui container">
|
||||||
<h1>Build your own ESP32-NMEA2000</h1>
|
<h1>Build your own ESP32-NMEA2000</h1>
|
||||||
<h3>New Build</h3>
|
<h3>New Build</h3>
|
||||||
|
<div class="row">
|
||||||
|
<span class="label" id="branchOrTag"></span>
|
||||||
|
<span class="value" id="branchOrTagValue">---</span>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<span class="label" >GitSha</span>
|
||||||
|
<span class="value" id="gitSha">---</span>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<button id="downloadConfig">SaveCfg</button>
|
<button id="downloadConfig">SaveCfg</button>
|
||||||
<button id="uploadConfig">LoadCfg</button>
|
<button id="uploadConfig">LoadCfg</button>
|
||||||
|
|
|
@ -4,7 +4,10 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
|
||||||
(function(){
|
(function(){
|
||||||
const STATUS_INTERVAL=2000;
|
const STATUS_INTERVAL=2000;
|
||||||
const CURRENT_PIPELINE='pipeline';
|
const CURRENT_PIPELINE='pipeline';
|
||||||
let API="cibuild.php";
|
const API="cibuild.php";
|
||||||
|
const GITAPI="install.php";
|
||||||
|
const GITUSER="wellenvogel";
|
||||||
|
const GITREPO="esp32-nmea2000";
|
||||||
let currentPipeline=undefined;
|
let currentPipeline=undefined;
|
||||||
let downloadUrl=undefined;
|
let downloadUrl=undefined;
|
||||||
let timer=undefined;
|
let timer=undefined;
|
||||||
|
@ -15,6 +18,7 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
|
||||||
let displayMode='last';
|
let displayMode='last';
|
||||||
let delayedSearch=undefined;
|
let delayedSearch=undefined;
|
||||||
let running=false;
|
let running=false;
|
||||||
|
let gitSha=undefined;
|
||||||
if (! branch) branch='master';
|
if (! branch) branch='master';
|
||||||
const modeStrings={
|
const modeStrings={
|
||||||
last: 'Last Build',
|
last: 'Last Build',
|
||||||
|
@ -123,6 +127,7 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
|
||||||
setValue('status','requested');
|
setValue('status','requested');
|
||||||
setValue('pipeline','');
|
setValue('pipeline','');
|
||||||
setRunning(true);
|
setRunning(true);
|
||||||
|
if (gitSha !== undefined) param.tag=gitSha;
|
||||||
param.config=JSON.stringify(config);
|
param.config=JSON.stringify(config);
|
||||||
fetchJson(API,Object.assign({
|
fetchJson(API,Object.assign({
|
||||||
api:'start'},param))
|
api:'start'},param))
|
||||||
|
@ -324,6 +329,7 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
|
||||||
}
|
}
|
||||||
let param={find:1};
|
let param={find:1};
|
||||||
fillValues(param,['environment','buildflags']);
|
fillValues(param,['environment','buildflags']);
|
||||||
|
if (gitSha !== undefined) param.tag=gitSha;
|
||||||
fetchJson(API,param)
|
fetchJson(API,param)
|
||||||
.then((res)=>{
|
.then((res)=>{
|
||||||
setCurrentPipeline(res.pipeline);
|
setCurrentPipeline(res.pipeline);
|
||||||
|
@ -347,6 +353,56 @@ import fileDownload from "https://cdn.skypack.dev/js-file-download@0.4.12"
|
||||||
}
|
}
|
||||||
structure=await loadConfig("build.yaml");
|
structure=await loadConfig("build.yaml");
|
||||||
buildSelectors(ROOT_PATH,structure.config.children,true);
|
buildSelectors(ROOT_PATH,structure.config.children,true);
|
||||||
//buildValues();
|
let gitParam={user:GITUSER,repo:GITREPO};
|
||||||
|
let branch=getParam('branch');
|
||||||
|
if (branch){
|
||||||
|
try{
|
||||||
|
let info=await fetchJson(GITAPI,Object.assign({},gitParam,{branch:branch}));
|
||||||
|
if (info.object){
|
||||||
|
gitSha=info.object.sha;
|
||||||
|
setValue('branchOrTag','branch');
|
||||||
|
setValue('branchOrTagValue',branch);
|
||||||
|
}
|
||||||
|
}catch (e){
|
||||||
|
console.log("branch query error",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gitSha === undefined) {
|
||||||
|
let tag = getParam('tag');
|
||||||
|
if (!tag) {
|
||||||
|
try {
|
||||||
|
let relinfo = await fetchJson(GITAPI, Object.assign({}, gitParam, { api: 1 }));
|
||||||
|
if (relinfo.tag_name) {
|
||||||
|
tag = relinfo.tag_name;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
alert("unable to query latest release");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
alert("unable to query release info " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tag){
|
||||||
|
try{
|
||||||
|
let info=await fetchJson(GITAPI,Object.assign({},gitParam,{tag:tag}));
|
||||||
|
if (info.object){
|
||||||
|
gitSha=info.object.sha;
|
||||||
|
setValue('branchOrTag','tag');
|
||||||
|
setValue('branchOrTagValue',tag);
|
||||||
|
}
|
||||||
|
}catch(e){
|
||||||
|
alert("cannot get sha for tag "+tag+": "+e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gitSha === undefined){
|
||||||
|
//last resort: no sha, let the CI pick up latest
|
||||||
|
setValue('gitSha','unknown');
|
||||||
|
setValue('branchOrTag','branch');
|
||||||
|
setValue('branchOrTagValue','master');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
setValue('gitSha',gitSha);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
|
@ -57,7 +57,7 @@ const fillValues=(values,items)=>{
|
||||||
const setValue=(id,value)=>{
|
const setValue=(id,value)=>{
|
||||||
let el=document.getElementById(id);
|
let el=document.getElementById(id);
|
||||||
if (! el) return;
|
if (! el) return;
|
||||||
if (el.tagName == 'DIV'){
|
if (el.tagName == 'DIV' || el.tagName == 'SPAN' || el.tagName == 'P'){
|
||||||
el.textContent=value;
|
el.textContent=value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
include("functions.php");
|
include("functions.php");
|
||||||
include("config.php");
|
include("config.php");
|
||||||
$api = "https://api.github.com/repos/#user#/#repo#/releases/latest";
|
const API_BASE="https://api.github.com/repos/#user#/#repo#";
|
||||||
|
$api = API_BASE."/releases/latest";
|
||||||
|
$branchsha=API_BASE."/git/refs/heads/#branch#";
|
||||||
|
$tagsha=API_BASE."/git/refs/tags/#tag#";
|
||||||
$download = "https://github.com/#user#/#repo#/releases/download/#dlVersion#/#dlName#";
|
$download = "https://github.com/#user#/#repo#/releases/download/#dlVersion#/#dlName#";
|
||||||
$manifest = "?dlName=#mName#&dlVersion=#mVersion#&user=#user#&repo=#repo#";
|
$manifest = "?dlName=#mName#&dlVersion=#mVersion#&user=#user#&repo=#repo#";
|
||||||
try {
|
try {
|
||||||
|
@ -10,6 +13,18 @@ try {
|
||||||
proxy(replaceVars($api, $vars));
|
proxy(replaceVars($api, $vars));
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
if (isset($_REQUEST['branch'])){
|
||||||
|
$vars = fillUserAndRepo();
|
||||||
|
$vars = addVars($vars, array('branch'));
|
||||||
|
proxy(replaceVars($branchsha, $vars));
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
if (isset($_REQUEST['tag'])){
|
||||||
|
$vars = fillUserAndRepo();
|
||||||
|
$vars = addVars($vars, array('tag'));
|
||||||
|
proxy(replaceVars($tagsha, $vars));
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
if (isset($_REQUEST['dlName'])) {
|
if (isset($_REQUEST['dlName'])) {
|
||||||
$vars = fillUserAndRepo();
|
$vars = fillUserAndRepo();
|
||||||
$vars = addVars($vars, array('dlName', 'dlVersion'));
|
$vars = addVars($vars, array('dlName', 'dlVersion'));
|
||||||
|
|
Loading…
Reference in New Issue