Skip to content

Commit 19187c6

Browse files
cjlee01cjlee1
andauthored
feat: process github job to stage (#1044) (#1045)
Signed-off-by: Calvin Lee <[email protected]> Co-authored-by: Calvin Lee <[email protected]>
1 parent 1f3cb0b commit 19187c6

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

packages/ui/src/views/pipeline-edit/components/graph-implementation/utils/yaml-to-pipeline-graph.tsx

+19-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ export const yamlString2Nodes = (
2929
return yaml2Nodes(yamlJson, options)
3030
}
3131

32+
export const processGithubJobsToStages = (yamlJson: Record<string, any>) => {
33+
if (yamlJson.jobs) {
34+
yamlJson.pipeline = yamlJson.pipeline || {}
35+
yamlJson.pipeline.stages = yamlJson.pipeline.stages || []
36+
37+
Object.entries(yamlJson.jobs).forEach(([key, value]) => {
38+
if (typeof value === 'object' && value !== null) {
39+
yamlJson.pipeline.stages.push({ ...value, id: key, name: key })
40+
}
41+
})
42+
43+
delete yamlJson.jobs
44+
return yamlJson
45+
}
46+
return yamlJson
47+
}
48+
3249
export const yaml2Nodes = (
3350
yamlObject: Record<string, any>,
3451
options: {
@@ -37,8 +54,8 @@ export const yaml2Nodes = (
3754
} = {}
3855
): AnyContainerNodeType[] => {
3956
const nodes: AnyContainerNodeType[] = []
40-
41-
const stages = yamlObject?.pipeline?.stages ?? []
57+
const processedYamlObject = processGithubJobsToStages(yamlObject)
58+
const stages = processedYamlObject?.pipeline?.stages ?? []
4259

4360
if (stages) {
4461
const stagesNodes = processStages(stages, 'pipeline.stages', options)

0 commit comments

Comments
 (0)