Add support for new snapshot keyword and object into workflow parser
This commit is contained in:
@@ -16,7 +16,7 @@ export function convertJob(context: TemplateContext, jobKey: StringToken, token:
|
|||||||
context.error(jobKey, error);
|
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 needs: StringToken[] | undefined = undefined;
|
||||||
let steps: Step[] = [];
|
let steps: Step[] = [];
|
||||||
let workflowJobRef: StringToken | undefined;
|
let workflowJobRef: StringToken | undefined;
|
||||||
@@ -86,6 +86,10 @@ export function convertJob(context: TemplateContext, jobKey: StringToken, token:
|
|||||||
services = item.value;
|
services = item.value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "snapshot":
|
||||||
|
snapshot = item.value;
|
||||||
|
break;
|
||||||
|
|
||||||
case "steps":
|
case "steps":
|
||||||
steps = convertSteps(context, item.value);
|
steps = convertSteps(context, item.value);
|
||||||
break;
|
break;
|
||||||
@@ -147,7 +151,8 @@ export function convertJob(context: TemplateContext, jobKey: StringToken, token:
|
|||||||
container,
|
container,
|
||||||
services,
|
services,
|
||||||
outputs,
|
outputs,
|
||||||
steps
|
steps,
|
||||||
|
snapshot
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export type BaseJob = {
|
|||||||
concurrency?: TemplateToken;
|
concurrency?: TemplateToken;
|
||||||
strategy?: TemplateToken;
|
strategy?: TemplateToken;
|
||||||
outputs?: MappingToken;
|
outputs?: MappingToken;
|
||||||
|
snapshot?: TemplateToken;
|
||||||
};
|
};
|
||||||
|
|
||||||
// `job-factory` in the schema
|
// `job-factory` in the schema
|
||||||
|
|||||||
@@ -1710,7 +1710,8 @@
|
|||||||
"concurrency": "job-concurrency",
|
"concurrency": "job-concurrency",
|
||||||
"outputs": "job-outputs",
|
"outputs": "job-outputs",
|
||||||
"defaults": "job-defaults",
|
"defaults": "job-defaults",
|
||||||
"steps": "steps"
|
"steps": "steps",
|
||||||
|
"snapshot": "snapshot"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1732,7 +1733,8 @@
|
|||||||
"if": "job-if",
|
"if": "job-if",
|
||||||
"permissions": "permissions",
|
"permissions": "permissions",
|
||||||
"concurrency": "job-concurrency",
|
"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": {
|
"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.",
|
"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": {
|
"mapping": {
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
include-source: false # Drop file/line/col from output
|
||||||
|
---
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo hi
|
||||||
|
snapshot:
|
||||||
|
image-name: custom-image
|
||||||
|
version: 1.*
|
||||||
|
if: ${{ always() }}
|
||||||
|
---
|
||||||
|
{
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"type": "job",
|
||||||
|
"id": "build",
|
||||||
|
"name": "build",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"runs-on": "ubuntu-latest",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"id": "__run",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"run": "echo hi"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"snapshot": {
|
||||||
|
"type": 2,
|
||||||
|
"map": [
|
||||||
|
{
|
||||||
|
"Key": "image-name",
|
||||||
|
"Value": "custom-image"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Key": "version",
|
||||||
|
"Value": "1.*"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Key": "if",
|
||||||
|
"Value": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "always()"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
include-source: false # Drop file/line/col from output
|
||||||
|
---
|
||||||
|
# on: push
|
||||||
|
# jobs:
|
||||||
|
# job1:
|
||||||
|
# runs-on: windows-2019
|
||||||
|
# snapshot: custom-image
|
||||||
|
# steps:
|
||||||
|
# - run: echo 1
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo hi
|
||||||
|
snapshot: custom-image
|
||||||
|
---
|
||||||
|
{
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"type": "job",
|
||||||
|
"id": "build",
|
||||||
|
"name": "build",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"runs-on": "ubuntu-latest",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"id": "__run",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"run": "echo hi"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"snapshot": "custom-image"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user