diff --git a/common/processWorkflows.js b/common/processWorkflows.js index 407b7bae5..e5c501245 100644 --- a/common/processWorkflows.js +++ b/common/processWorkflows.js @@ -42,6 +42,18 @@ function processJsonStep(json, args) { if (conditionMatch(item._if, args)) { res.push(_.omit(item, ['_if'])); } + } else if (item._replace || item._include) { + const replaceWith = item._replace ? args.replace?.[item._replace] : includes[item._include]; + if (replaceWith) { + modified = true; + if (_.isArray(replaceWith)) { + res.push(...replaceWith); + } else { + res.push(replaceWith); + } + } else { + res.push(item); + } } else { res.push(item); } @@ -49,27 +61,27 @@ function processJsonStep(json, args) { return res; } - if (value?.run && _.isArray(value.run)) { - const newrun = []; - for (const item of value.run) { - let replaced = false; - for (const repl of args.run) { - if (item == repl.from) { - replaced = true; - modified = true; - newrun.push(...repl.to); - break; - } - } - if (!replaced) { - newrun.push(item); - } - } - return { - ...value, - run: newrun, - }; - } + // if (value?.run && _.isArray(value.run)) { + // const newrun = []; + // for (const item of value.run) { + // let replaced = false; + // for (const repl of args.run) { + // if (item == repl.from) { + // replaced = true; + // modified = true; + // newrun.push(...repl.to); + // break; + // } + // } + // if (!replaced) { + // newrun.push(item); + // } + // } + // return { + // ...value, + // run: newrun, + // }; + // } if (_.isPlainObject(value)) { if (_.intersection(args.allNames ?? [], Object.keys(value))?.length > 0) { @@ -81,6 +93,10 @@ function processJsonStep(json, args) { if (value?._include) { return includes[value?._include]; } + + if (value?._replace) { + return args?.replace[value?._replace]; + } }); } diff --git a/workflow-templates/build-docker.tpl.yaml b/workflow-templates/build-docker.tpl.yaml index be5080d10..5c3169818 100644 --- a/workflow-templates/build-docker.tpl.yaml +++ b/workflow-templates/build-docker.tpl.yaml @@ -1,16 +1,16 @@ _templates: _community: file: build-docker.yaml - run: - - from: _cd_merged - to: [] + replace: + _cd_merged: + - cd .. + - cd dbgate-merged _premium: file: build-docker-pro.yaml - run: - - from: _cd_merged - to: - - cd .. - - cd dbgate-merged + replace: + _cd_merged: + - cd .. + - cd dbgate-merged name: _community: Docker image Community