cue.dev/x/githubactions@v0.5.0

Action.cue raw

  1package githubactions
  2
  3#Action: {
  4	@jsonschema(schema="http://json-schema.org/draft-07/schema#")
  5	@jsonschema(id="https://json.schemastore.org/github-action.json")
  6	matchIf({
  7		"runs"?: null | bool | number | string | [...] | {
  8			"using"?: "composite"
  9			...
 10		}
 11		...
 12	}, {
 13		"outputs"?: #."outputs-composite"
 14		...
 15	}, {
 16		"outputs"?: #outputs
 17		...
 18	}) & close({
 19		// The name of your action. GitHub displays the `name` in the
 20		// Actions tab to help visually identify actions in each job.
 21		"name"!: string
 22
 23		// The name of the action's author.
 24		"author"?: string
 25
 26		// A short description of the action.
 27		"description"!: string
 28
 29		// Input parameters allow you to specify data that the action
 30		// expects to use during runtime. GitHub stores input parameters
 31		// as environment variables. Input ids with uppercase letters are
 32		// converted to lowercase during runtime. We recommended using
 33		// lowercase input ids.
 34		"inputs"?: close({
 35			{[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$"]: close({
 36				// A string description of the input parameter.
 37				"description"!: string
 38
 39				// A string shown to users using the deprecated input.
 40				"deprecationMessage"?: string
 41
 42				// A boolean to indicate whether the action requires the input
 43				// parameter. Set to `true` when the parameter is required.
 44				"required"?: bool
 45
 46				// A string representing the default value. The default value is
 47				// used when an input parameter isn't specified in a workflow
 48				// file.
 49				"default"?: string
 50			})
 51			}
 52		})
 53		"outputs"?: _
 54		"runs"!: matchN(1, [#."runs-javascript", #."runs-composite", #."runs-docker"])
 55
 56		// You can use a color and Feather icon to create a badge to
 57		// personalize and distinguish your action. Badges are shown next
 58		// to your action name in GitHub Marketplace.
 59		"branding"?: close({
 60			// The background color of the badge.
 61			"color"?: "white" | "black" | "yellow" | "blue" | "green" | "orange" | "red" | "purple" | "gray-dark"
 62
 63			// The name of the Feather icon to use.
 64			"icon"?: "activity" | "airplay" | "alert-circle" | "alert-octagon" | "alert-triangle" | "align-center" | "align-justify" | "align-left" | "align-right" | "anchor" | "aperture" | "archive" | "arrow-down-circle" | "arrow-down-left" | "arrow-down-right" | "arrow-down" | "arrow-left-circle" | "arrow-left" | "arrow-right-circle" | "arrow-right" | "arrow-up-circle" | "arrow-up-left" | "arrow-up-right" | "arrow-up" | "at-sign" | "award" | "bar-chart-2" | "bar-chart" | "battery-charging" | "battery" | "bell-off" | "bell" | "bluetooth" | "bold" | "book-open" | "book" | "bookmark" | "box" | "briefcase" | "calendar" | "camera-off" | "camera" | "cast" | "check-circle" | "check-square" | "check" | "chevron-down" | "chevron-left" | "chevron-right" | "chevron-up" | "chevrons-down" | "chevrons-left" | "chevrons-right" | "chevrons-up" | "circle" | "clipboard" | "clock" | "cloud-drizzle" | "cloud-lightning" | "cloud-off" | "cloud-rain" | "cloud-snow" | "cloud" | "code" | "command" | "compass" | "copy" | "corner-down-left" | "corner-down-right" | "corner-left-down" | "corner-left-up" | "corner-right-down" | "corner-right-up" | "corner-up-left" | "corner-up-right" | "cpu" | "credit-card" | "crop" | "crosshair" | "database" | "delete" | "disc" | "dollar-sign" | "download-cloud" | "download" | "droplet" | "edit-2" | "edit-3" | "edit" | "external-link" | "eye-off" | "eye" | "fast-forward" | "feather" | "file-minus" | "file-plus" | "file-text" | "file" | "film" | "filter" | "flag" | "folder-minus" | "folder-plus" | "folder" | "gift" | "git-branch" | "git-commit" | "git-merge" | "git-pull-request" | "globe" | "grid" | "hard-drive" | "hash" | "headphones" | "heart" | "help-circle" | "home" | "image" | "inbox" | "info" | "italic" | "layers" | "layout" | "life-buoy" | "link-2" | "link" | "list" | "loader" | "lock" | "log-in" | "log-out" | "mail" | "map-pin" | "map" | "maximize-2" | "maximize" | "menu" | "message-circle" | "message-square" | "mic-off" | "mic" | "minimize-2" | "minimize" | "minus-circle" | "minus-square" | "minus" | "monitor" | "moon" | "more-horizontal" | "more-vertical" | "move" | "music" | "navigation-2" | "navigation" | "octagon" | "package" | "paperclip" | "pause-circle" | "pause" | "percent" | "phone-call" | "phone-forwarded" | "phone-incoming" | "phone-missed" | "phone-off" | "phone-outgoing" | "phone" | "pie-chart" | "play-circle" | "play" | "plus-circle" | "plus-square" | "plus" | "pocket" | "power" | "printer" | "radio" | "refresh-ccw" | "refresh-cw" | "repeat" | "rewind" | "rotate-ccw" | "rotate-cw" | "rss" | "save" | "scissors" | "search" | "send" | "server" | "settings" | "share-2" | "share" | "shield-off" | "shield" | "shopping-bag" | "shopping-cart" | "shuffle" | "sidebar" | "skip-back" | "skip-forward" | "slash" | "sliders" | "smartphone" | "speaker" | "square" | "star" | "stop-circle" | "sun" | "sunrise" | "sunset" | "table" | "tablet" | "tag" | "target" | "terminal" | "thermometer" | "thumbs-down" | "thumbs-up" | "toggle-left" | "toggle-right" | "trash-2" | "trash" | "trending-down" | "trending-up" | "triangle" | "truck" | "tv" | "type" | "umbrella" | "underline" | "unlock" | "upload-cloud" | "upload" | "user-check" | "user-minus" | "user-plus" | "user-x" | "user" | "users" | "video-off" | "video" | "voicemail" | "volume-1" | "volume-2" | "volume-x" | "volume" | "watch" | "wifi-off" | "wifi" | "wind" | "x-circle" | "x-square" | "x" | "zap-off" | "zap" | "zoom-in" | "zoom-out"
 65		})
 66	})
 67
 68	// Output parameters allow you to declare data that an action
 69	// sets. Actions that run later in a workflow can use the output
 70	// data set in previously run actions. For example, if you had an
 71	// action that performed the addition of two inputs (x + y = z),
 72	// the action could output the sum (z) for other actions to use
 73	// as an input.
 74	// If you don't declare an output in your action metadata file,
 75	// you can still set outputs and use them in a workflow.
 76	#: "outputs-composite": close({
 77		{[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$"]: close({
 78			// A string description of the output parameter.
 79			"description"!: string
 80
 81			// The value that the output parameter will be mapped to. You can
 82			// set this to a string or an expression with context. For
 83			// example, you can use the steps context to set the value of an
 84			// output to the output value of a step.
 85			"value"!: string
 86		})
 87		}
 88	})
 89
 90	// Allows you to define conditions for the `post:` action
 91	// execution. The `post:` action will only run if the conditions
 92	// in `post-if` are met. If not set, then `post-if` defaults to
 93	// `always()`.
 94	#: "post-if": string
 95
 96	// Allows you to define conditions for the `pre:` action
 97	// execution. The `pre:` action will only run if the conditions
 98	// in `pre-if` are met. If not set, then `pre-if` defaults to
 99	// `always()`. Note that the `step` context is unavailable, as no
100	// steps have run yet.
101	#: "pre-if": string
102
103	// Configures the path to the composite action, and the
104	// application used to execute the code.
105	#: "runs-composite": close({
106		// To use a composite run steps action, set this to 'composite'.
107		"using"!: "composite"
108
109		// The run steps that you plan to run in this action.
110		"steps"!: [...matchN(1, [{
111			"run"!:   _
112			"shell"!: _
113			...
114		}, {
115			"uses"!: _
116			...
117		}]) & close({
118			// The command you want to run. This can be inline or a script in
119			// your action repository.
120			"run"?: string
121
122			// The shell where you want to run the command.
123			"shell"?: matchN(>=1, [string, "bash" | "pwsh" | "python" | "sh" | "cmd" | "powershell"])
124
125			// Selects an action to run as part of a step in your job.
126			"uses"?: string
127
128			// A map of the input parameters defined by the action. Each input
129			// parameter is a key/value pair. Input parameters are set as
130			// environment variables. The variable is prefixed with INPUT_
131			// and converted to upper case.
132			"with"?: {
133				...
134			}
135
136			// The name of the composite run step.
137			"name"?: string
138
139			// A unique identifier for the step. You can use the `id` to
140			// reference the step in contexts.
141			"id"?: string
142
143			// You can use the if conditional to prevent a step from running
144			// unless a condition is met. You can use any supported context
145			// and expression to create a conditional.
146			// Expressions in an if conditional do not require the ${{ }}
147			// syntax. However, you must always use the ${{ }} expression
148			// syntax or escape with '', "", or () when the expression starts
149			// with !, since ! is reserved notation in YAML format. For more
150			// information, see
151			// https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions
152			"if"?: string
153
154			// Sets a map of environment variables for only that step.
155			"env"?: matchN(1, [{
156				[string]: bool | number | string
157			}, #stringContainingExpressionSyntax])
158
159			// Prevents a job from failing when a step fails. Set to true to
160			// allow a job to pass when this step fails.
161			"continue-on-error"?: matchN(1, [bool, #expressionSyntax])
162
163			// Specifies the working directory where the command is run.
164			"working-directory"?: string
165		})]
166	})
167
168	// Configures the image used for the Docker action.
169	#: "runs-docker": close({
170		// You must set this value to 'docker'.
171		"using"!: "docker"
172
173		// The Docker image to use as the container to run the action. The
174		// value can be the Docker base image name, a local `Dockerfile`
175		// in your repository, or a public image in Docker Hub or another
176		// registry. To reference a `Dockerfile` local to your
177		// repository, use a path relative to your action metadata file.
178		// The `docker` application will execute this file.
179		"image"!: string
180
181		// Specifies a key/value map of environment variables to set in
182		// the container environment.
183		"env"?: matchN(1, [{
184			[string]: bool | number | string
185		}, #stringContainingExpressionSyntax])
186
187		// Overrides the Docker `ENTRYPOINT` in the `Dockerfile`, or sets
188		// it if one wasn't already specified. Use `entrypoint` when the
189		// `Dockerfile` does not specify an `ENTRYPOINT` or you want to
190		// override the `ENTRYPOINT` instruction. If you omit
191		// `entrypoint`, the commands you specify in the Docker
192		// `ENTRYPOINT` instruction will execute. The Docker `ENTRYPOINT
193		// instruction has a *shell* form and *exec* form. The Docker
194		// `ENTRYPOINT` documentation recommends using the *exec* form of
195		// the `ENTRYPOINT` instruction.
196		"entrypoint"?: string
197
198		// Allows you to run a script before the `entrypoint` action
199		// begins. For example, you can use `pre-entrypoint:` to run a
200		// prerequisite setup script. GitHub Actions uses `docker run` to
201		// launch this action, and runs the script inside a new container
202		// that uses the same base image. This means that the runtime
203		// state is different from the main `entrypoint` container, and
204		// any states you require must be accessed in either the
205		// workspace, `HOME`, or as a `STATE_` variable. The
206		// `pre-entrypoint:` action always runs by default but you can
207		// override this using `pre-if`.
208		"pre-entrypoint"?: string
209		"pre-if"?:         #."pre-if"
210
211		// Allows you to run a cleanup script once the `runs.entrypoint`
212		// action has completed. GitHub Actions uses `docker run` to
213		// launch this action. Because GitHub Actions runs the script
214		// inside a new container using the same base image, the runtime
215		// state is different from the main `entrypoint` container. You
216		// can access any state you need in either the workspace, `HOME`,
217		// or as a `STATE_` variable. The `post-entrypoint:` action
218		// always runs by default but you can override this using
219		// `post-if`.
220		"post-entrypoint"?: string
221		"post-if"?:         #."post-if"
222
223		// An array of strings that define the inputs for a Docker
224		// container. Inputs can include hardcoded strings. GitHub passes
225		// the `args` to the container's `ENTRYPOINT` when the container
226		// starts up.
227		// The `args` are used in place of the `CMD` instruction in a
228		// `Dockerfile`. If you use `CMD` in your `Dockerfile`, use the
229		// guidelines ordered by preference:
230		// - Document required arguments in the action's README and omit
231		// them from the `CMD` instruction.
232		// - Use defaults that allow using the action without specifying
233		// any `args`.
234		// - If the action exposes a `--help` flag, or something similar,
235		// use that to make your action self-documenting.
236		"args"?: [...string]
237	})
238
239	// Configures the path to the action's code and the application
240	// used to execute the code.
241	#: "runs-javascript": close({
242		// The application used to execute the code specified in `main`.
243		"using"!: "node12" | "node16" | "node20" | "node24"
244
245		// The file that contains your action code. The application
246		// specified in `using` executes this file.
247		"main"!: string
248
249		// Allows you to run a script at the start of a job, before the
250		// `main:` action begins. For example, you can use `pre:` to run
251		// a prerequisite setup script. The application specified with
252		// the `using` syntax will execute this file. The `pre:` action
253		// always runs by default but you can override this using
254		// `pre-if`.
255		"pre"?:    string
256		"pre-if"?: #."pre-if"
257
258		// Allows you to run a script at the end of a job, once the
259		// `main:` action has completed. For example, you can use `post:`
260		// to terminate certain processes or remove unneeded files. The
261		// application specified with the `using` syntax will execute
262		// this file. The `post:` action always runs by default but you
263		// can override this using `post-if`.
264		"post"?:    string
265		"post-if"?: #."post-if"
266	})
267
268	#expressionSyntax: =~"""
269		^\\$\\{\\{(.|[\r
270		])*\\}\\}$
271		"""
272
273	// Output parameters allow you to declare data that an action
274	// sets. Actions that run later in a workflow can use the output
275	// data set in previously run actions. For example, if you had an
276	// action that performed the addition of two inputs (x + y = z),
277	// the action could output the sum (z) for other actions to use
278	// as an input.
279	// If you don't declare an output in your action metadata file,
280	// you can still set outputs and use them in a workflow.
281	#outputs: close({
282		{[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$"]: close({
283			// A string description of the output parameter.
284			"description"!: string
285		})
286		}
287	})
288
289	#stringContainingExpressionSyntax: =~"""
290		^.*\\$\\{\\{(.|[\r
291		])*\\}\\}.*$
292		"""
293}