Merge pull request #206 from lawrencegripper/lg/image-event
Add `on.image_version` support to language parser
This commit is contained in:
@@ -7,10 +7,12 @@ import {TokenType} from "../../templates/tokens/types";
|
|||||||
import {
|
import {
|
||||||
BranchFilterConfig,
|
BranchFilterConfig,
|
||||||
EventsConfig,
|
EventsConfig,
|
||||||
|
NamesFilterConfig,
|
||||||
PathFilterConfig,
|
PathFilterConfig,
|
||||||
ScheduleConfig,
|
ScheduleConfig,
|
||||||
TagFilterConfig,
|
TagFilterConfig,
|
||||||
TypesFilterConfig,
|
TypesFilterConfig,
|
||||||
|
VersionsFilterConfig,
|
||||||
WorkflowFilterConfig
|
WorkflowFilterConfig
|
||||||
} from "../workflow-template";
|
} from "../workflow-template";
|
||||||
import {isValidCron} from "./cron";
|
import {isValidCron} from "./cron";
|
||||||
@@ -76,10 +78,11 @@ export function convertOn(context: TemplateContext, token: TemplateToken): Event
|
|||||||
...convertPatternFilter("tags", eventToken),
|
...convertPatternFilter("tags", eventToken),
|
||||||
...convertPatternFilter("paths", eventToken),
|
...convertPatternFilter("paths", eventToken),
|
||||||
...convertFilter("types", eventToken),
|
...convertFilter("types", eventToken),
|
||||||
|
...convertFilter("versions", eventToken),
|
||||||
|
...convertFilter("names", eventToken),
|
||||||
...convertFilter("workflows", eventToken)
|
...convertFilter("workflows", eventToken)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,8 +124,8 @@ function convertPatternFilter<T extends BranchFilterConfig & TagFilterConfig & P
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertFilter<T extends TypesFilterConfig & WorkflowFilterConfig>(
|
function convertFilter<T extends TypesFilterConfig & WorkflowFilterConfig & VersionsFilterConfig & NamesFilterConfig>(
|
||||||
name: "types" | "workflows",
|
name: "types" | "workflows" | "versions" | "names",
|
||||||
token: MappingToken
|
token: MappingToken
|
||||||
): T {
|
): T {
|
||||||
const result = {} as T;
|
const result = {} as T;
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ export type EventsConfig = {
|
|||||||
repository_dispatch?: TypesFilterConfig;
|
repository_dispatch?: TypesFilterConfig;
|
||||||
release?: TypesFilterConfig;
|
release?: TypesFilterConfig;
|
||||||
watch?: TypesFilterConfig;
|
watch?: TypesFilterConfig;
|
||||||
|
image_versions?: TypesFilterConfig & VersionsFilterConfig & NamesFilterConfig;
|
||||||
|
|
||||||
// Index signature to allow easier lookup
|
// Index signature to allow easier lookup
|
||||||
[eventName: string]: unknown;
|
[eventName: string]: unknown;
|
||||||
@@ -139,6 +140,14 @@ export type TypesFilterConfig = {
|
|||||||
types?: string[];
|
types?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type VersionsFilterConfig = {
|
||||||
|
versions?: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type NamesFilterConfig = {
|
||||||
|
names?: string[];
|
||||||
|
};
|
||||||
|
|
||||||
export type BranchFilterConfig = {
|
export type BranchFilterConfig = {
|
||||||
branches?: string[];
|
branches?: string[];
|
||||||
"branches-ignore"?: string[];
|
"branches-ignore"?: string[];
|
||||||
|
|||||||
@@ -99,6 +99,7 @@
|
|||||||
"discussion_comment": "discussion-comment",
|
"discussion_comment": "discussion-comment",
|
||||||
"fork": "fork",
|
"fork": "fork",
|
||||||
"gollum": "gollum",
|
"gollum": "gollum",
|
||||||
|
"image_version": "image-version",
|
||||||
"issue_comment": "issue-comment",
|
"issue_comment": "issue-comment",
|
||||||
"issues": "issues",
|
"issues": "issues",
|
||||||
"label": "label",
|
"label": "label",
|
||||||
@@ -140,6 +141,7 @@
|
|||||||
"discussion-comment-string",
|
"discussion-comment-string",
|
||||||
"fork-string",
|
"fork-string",
|
||||||
"gollum-string",
|
"gollum-string",
|
||||||
|
"image-version-string",
|
||||||
"issue-comment-string",
|
"issue-comment-string",
|
||||||
"issues-string",
|
"issues-string",
|
||||||
"label-string",
|
"label-string",
|
||||||
@@ -436,6 +438,47 @@
|
|||||||
"description": "Runs your workflow when someone creates or updates a Wiki page.",
|
"description": "Runs your workflow when someone creates or updates a Wiki page.",
|
||||||
"null": {}
|
"null": {}
|
||||||
},
|
},
|
||||||
|
"image-version-string": {
|
||||||
|
"description": "Runs your workflow when an image version is created or changes state.",
|
||||||
|
"string": {
|
||||||
|
"constant": "image_version"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"image-version": {
|
||||||
|
"description": "Runs your workflow when an image version is created or changes state.",
|
||||||
|
"one-of": [
|
||||||
|
"null",
|
||||||
|
"image-version-mapping"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"image-version-mapping": {
|
||||||
|
"mapping": {
|
||||||
|
"properties": {
|
||||||
|
"types": "image-version-activity",
|
||||||
|
"names": "event-names",
|
||||||
|
"versions": "event-versions"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"image-version-activity": {
|
||||||
|
"description": "The types of image version activity that trigger the workflow. Supported activity types: `created`, `ready`, `deleted`.",
|
||||||
|
"one-of": [
|
||||||
|
"image-version-activity-type",
|
||||||
|
"image-version-activity-types"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"image-version-activity-types": {
|
||||||
|
"sequence": {
|
||||||
|
"item-type": "image-version-activity-type"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"image-version-activity-type": {
|
||||||
|
"allowed-values": [
|
||||||
|
"created",
|
||||||
|
"ready",
|
||||||
|
"deleted"
|
||||||
|
]
|
||||||
|
},
|
||||||
"issue-comment-string": {
|
"issue-comment-string": {
|
||||||
"description": "Runs your workflow when an issue or pull request comment is created, edited, or deleted.",
|
"description": "Runs your workflow when an issue or pull request comment is created, edited, or deleted.",
|
||||||
"string": {
|
"string": {
|
||||||
@@ -1221,6 +1264,13 @@
|
|||||||
"sequence-of-non-empty-string"
|
"sequence-of-non-empty-string"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"event-names": {
|
||||||
|
"description": "Use the `names` filter when you want to include names via patterns or when you want to both include and exclude names using patterns. ",
|
||||||
|
"one-of": [
|
||||||
|
"non-empty-string",
|
||||||
|
"sequence-of-non-empty-string"
|
||||||
|
]
|
||||||
|
},
|
||||||
"event-tags": {
|
"event-tags": {
|
||||||
"description": "Use the `tags` filter when you want to include tag name patterns or when you want to both include and exclude tag names patterns. You cannot use both the `tags` and `tags-ignore` filters for the same event in a workflow.",
|
"description": "Use the `tags` filter when you want to include tag name patterns or when you want to both include and exclude tag names patterns. You cannot use both the `tags` and `tags-ignore` filters for the same event in a workflow.",
|
||||||
"one-of": [
|
"one-of": [
|
||||||
@@ -1249,6 +1299,13 @@
|
|||||||
"sequence-of-non-empty-string"
|
"sequence-of-non-empty-string"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"event-versions": {
|
||||||
|
"description": "Use the `versions` filter when you want to include versions via patterns or when you want to both include and exclude versions using patterns. ",
|
||||||
|
"one-of": [
|
||||||
|
"non-empty-string",
|
||||||
|
"sequence-of-non-empty-string"
|
||||||
|
]
|
||||||
|
},
|
||||||
"repository-dispatch-string": {
|
"repository-dispatch-string": {
|
||||||
"description": "You can use the GitHub API to trigger a webhook event called `repository_dispatch` when you want to trigger a workflow for activity that happens outside of GitHub.",
|
"description": "You can use the GitHub API to trigger a webhook event called `repository_dispatch` when you want to trigger a workflow for activity that happens outside of GitHub.",
|
||||||
"string": {
|
"string": {
|
||||||
|
|||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
include-source: false
|
||||||
|
skip:
|
||||||
|
- C#
|
||||||
|
- Go
|
||||||
|
---
|
||||||
|
on:
|
||||||
|
image_version:
|
||||||
|
names: testing
|
||||||
|
versions: 1.*
|
||||||
|
jobs:
|
||||||
|
my-job:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo hi
|
||||||
|
---
|
||||||
|
{
|
||||||
|
"events": {
|
||||||
|
"image_version": {
|
||||||
|
"versions": [
|
||||||
|
"1.*"
|
||||||
|
],
|
||||||
|
"names": [
|
||||||
|
"testing"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"type": "job",
|
||||||
|
"id": "my-job",
|
||||||
|
"name": "my-job",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"runs-on": "ubuntu-latest",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"id": "__run",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"run": "echo hi"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
include-source: false
|
||||||
|
skip:
|
||||||
|
- C#
|
||||||
|
- Go
|
||||||
|
---
|
||||||
|
on:
|
||||||
|
image_version:
|
||||||
|
types:
|
||||||
|
- ready
|
||||||
|
names:
|
||||||
|
- one
|
||||||
|
- two
|
||||||
|
jobs:
|
||||||
|
my-job:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo hi
|
||||||
|
---
|
||||||
|
{
|
||||||
|
"events": {
|
||||||
|
"image_version": {
|
||||||
|
"types": [
|
||||||
|
"ready"
|
||||||
|
],
|
||||||
|
"names": [
|
||||||
|
"one",
|
||||||
|
"two"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"type": "job",
|
||||||
|
"id": "my-job",
|
||||||
|
"name": "my-job",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"runs-on": "ubuntu-latest",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"id": "__run",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"run": "echo hi"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
include-source: false
|
||||||
|
skip:
|
||||||
|
- C#
|
||||||
|
- Go
|
||||||
|
---
|
||||||
|
on:
|
||||||
|
image_version:
|
||||||
|
types:
|
||||||
|
- ready
|
||||||
|
versions:
|
||||||
|
- "1.0.0"
|
||||||
|
- "1.0.1"
|
||||||
|
jobs:
|
||||||
|
my-job:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo hi
|
||||||
|
---
|
||||||
|
{
|
||||||
|
"events": {
|
||||||
|
"image_version": {
|
||||||
|
"types": [
|
||||||
|
"ready"
|
||||||
|
],
|
||||||
|
"versions": [
|
||||||
|
"1.0.0",
|
||||||
|
"1.0.1"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"type": "job",
|
||||||
|
"id": "my-job",
|
||||||
|
"name": "my-job",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"runs-on": "ubuntu-latest",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"id": "__run",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"run": "echo hi"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
include-source: false
|
||||||
|
skip:
|
||||||
|
- C#
|
||||||
|
- Go
|
||||||
|
---
|
||||||
|
on: image_version
|
||||||
|
jobs:
|
||||||
|
my-job:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo hi
|
||||||
|
---
|
||||||
|
{
|
||||||
|
"events": {
|
||||||
|
"image_version": {}
|
||||||
|
},
|
||||||
|
"jobs": [
|
||||||
|
{
|
||||||
|
"type": "job",
|
||||||
|
"id": "my-job",
|
||||||
|
"name": "my-job",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"runs-on": "ubuntu-latest",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"id": "__run",
|
||||||
|
"if": {
|
||||||
|
"type": 3,
|
||||||
|
"expr": "success()"
|
||||||
|
},
|
||||||
|
"run": "echo hi"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user