Add support for new snapshot keyword and object into workflow parser

This commit is contained in:
lawrencegripper
2025-09-04 15:25:36 +00:00
committed by GitHub
parent ce274ee2ce
commit 4faa096820
5 changed files with 161 additions and 4 deletions
+7 -2
View File
@@ -16,7 +16,7 @@ export function convertJob(context: TemplateContext, jobKey: StringToken, token:
context.error(jobKey, error);
}
let concurrency, container, env, environment, name, outputs, runsOn, services, strategy: TemplateToken | undefined;
let concurrency, container, env, environment, name, outputs, runsOn, services, strategy, snapshot: TemplateToken | undefined;
let needs: StringToken[] | undefined = undefined;
let steps: Step[] = [];
let workflowJobRef: StringToken | undefined;
@@ -86,6 +86,10 @@ export function convertJob(context: TemplateContext, jobKey: StringToken, token:
services = item.value;
break;
case "snapshot":
snapshot = item.value;
break;
case "steps":
steps = convertSteps(context, item.value);
break;
@@ -147,7 +151,8 @@ export function convertJob(context: TemplateContext, jobKey: StringToken, token:
container,
services,
outputs,
steps
steps,
snapshot
};
}
}
@@ -41,6 +41,7 @@ export type BaseJob = {
concurrency?: TemplateToken;
strategy?: TemplateToken;
outputs?: MappingToken;
snapshot?: TemplateToken;
};
// `job-factory` in the schema
+54 -2
View File
@@ -1710,7 +1710,8 @@
"concurrency": "job-concurrency",
"outputs": "job-outputs",
"defaults": "job-defaults",
"steps": "steps"
"steps": "steps",
"snapshot": "snapshot"
}
}
},
@@ -1732,7 +1733,8 @@
"if": "job-if",
"permissions": "permissions",
"concurrency": "job-concurrency",
"strategy": "strategy"
"strategy": "strategy",
"snapshot": "snapshot"
}
}
},
@@ -1826,6 +1828,56 @@
}
}
},
"snapshot": {
"description": "Use `snapshot` to generate a custom image from this job",
"one-of": [
"string",
"snapshot-mapping"
]
},
"snapshot-mapping": {
"mapping": {
"properties": {
"if": "snapshot-if",
"image-name": {
"type": "non-empty-string",
"required": true,
"description": "The image name."
},
"version": {
"type": "string",
"description": "The major version to publish the snapshot as, use * to auto-increment minor version"
},
"tags": {
"type": "sequence-of-non-empty-string",
"description": "An array of tags to apply to the snapshot."
}
}
}
},
"snapshot-if": {
"description": "You can use the `if` conditional to prevent a snapshot from being created unless a condition is met. You can use any supported context and expression to create a conditional.",
"context": [
"github",
"inputs",
"vars",
"needs",
"strategy",
"matrix",
"steps",
"job",
"runner",
"env",
"always(0,0)",
"failure(0,0)",
"cancelled(0,0)",
"success(0,0)",
"hashFiles(1,255)"
],
"string": {
"is-expression": true
}
},
"matrix": {
"description": "Use `matrix` to define a matrix of different job configurations. Within your matrix, define one or more variables followed by an array of values.",
"mapping": {