cue.dev/x/githubactions@v0.9.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 Actions tab to
 20		// 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 expects to use
 30		// during runtime. GitHub stores input parameters as environment variables.
 31		// Input ids with uppercase letters are converted to lowercase during runtime.
 32		// We recommended using lowercase input ids.
 33		"inputs"?: close({
 34
 35			{
 36				[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$"]: close({
 37					// A string description of the input parameter.
 38					"description"!: string
 39
 40					// A string shown to users using the deprecated input.
 41					"deprecationMessage"?: string
 42
 43					// A boolean to indicate whether the action requires the input parameter. Set to
 44					// `true` when the parameter is required.
 45					"required"?: bool
 46
 47					// A string representing the default value. The default value is used when an
 48					// input parameter isn't specified in a workflow file.
 49					"default"?: string
 50				})
 51			}})
 52		"outputs"?: _
 53		"runs"!:    matchN(1, [#."runs-javascript", #."runs-composite", #."runs-docker"])
 54
 55		// You can use a color and Feather icon to create a badge to personalize and
 56		// distinguish your action. Badges are shown next to your action name in GitHub
 57		// Marketplace.
 58		"branding"?: close({
 59			// The background color of the badge.
 60			"color"?: "white" | "black" | "yellow" | "blue" | "green" | "orange" | "red" | "purple" | "gray-dark"
 61
 62			// The name of the Feather icon to use.
 63			"icon"?: "activity" |
 64				"airplay" |
 65				"alert-circle" |
 66				"alert-octagon" |
 67				"alert-triangle" |
 68				"align-center" |
 69				"align-justify" |
 70				"align-left" |
 71				"align-right" |
 72				"anchor" |
 73				"aperture" |
 74				"archive" |
 75				"arrow-down-circle" |
 76				"arrow-down-left" |
 77				"arrow-down-right" |
 78				"arrow-down" |
 79				"arrow-left-circle" |
 80				"arrow-left" |
 81				"arrow-right-circle" |
 82				"arrow-right" |
 83				"arrow-up-circle" |
 84				"arrow-up-left" |
 85				"arrow-up-right" |
 86				"arrow-up" |
 87				"at-sign" |
 88				"award" |
 89				"bar-chart-2" |
 90				"bar-chart" |
 91				"battery-charging" |
 92				"battery" |
 93				"bell-off" |
 94				"bell" |
 95				"bluetooth" |
 96				"bold" |
 97				"book-open" |
 98				"book" |
 99				"bookmark" |
100				"box" |
101				"briefcase" |
102				"calendar" |
103				"camera-off" |
104				"camera" |
105				"cast" |
106				"check-circle" |
107				"check-square" |
108				"check" |
109				"chevron-down" |
110				"chevron-left" |
111				"chevron-right" |
112				"chevron-up" |
113				"chevrons-down" |
114				"chevrons-left" |
115				"chevrons-right" |
116				"chevrons-up" |
117				"circle" |
118				"clipboard" |
119				"clock" |
120				"cloud-drizzle" |
121				"cloud-lightning" |
122				"cloud-off" |
123				"cloud-rain" |
124				"cloud-snow" |
125				"cloud" |
126				"code" |
127				"command" |
128				"compass" |
129				"copy" |
130				"corner-down-left" |
131				"corner-down-right" |
132				"corner-left-down" |
133				"corner-left-up" |
134				"corner-right-down" |
135				"corner-right-up" |
136				"corner-up-left" |
137				"corner-up-right" |
138				"cpu" |
139				"credit-card" |
140				"crop" |
141				"crosshair" |
142				"database" |
143				"delete" |
144				"disc" |
145				"dollar-sign" |
146				"download-cloud" |
147				"download" |
148				"droplet" |
149				"edit-2" |
150				"edit-3" |
151				"edit" |
152				"external-link" |
153				"eye-off" |
154				"eye" |
155				"fast-forward" |
156				"feather" |
157				"file-minus" |
158				"file-plus" |
159				"file-text" |
160				"file" |
161				"film" |
162				"filter" |
163				"flag" |
164				"folder-minus" |
165				"folder-plus" |
166				"folder" |
167				"gift" |
168				"git-branch" |
169				"git-commit" |
170				"git-merge" |
171				"git-pull-request" |
172				"globe" |
173				"grid" |
174				"hard-drive" |
175				"hash" |
176				"headphones" |
177				"heart" |
178				"help-circle" |
179				"home" |
180				"image" |
181				"inbox" |
182				"info" |
183				"italic" |
184				"layers" |
185				"layout" |
186				"life-buoy" |
187				"link-2" |
188				"link" |
189				"list" |
190				"loader" |
191				"lock" |
192				"log-in" |
193				"log-out" |
194				"mail" |
195				"map-pin" |
196				"map" |
197				"maximize-2" |
198				"maximize" |
199				"menu" |
200				"message-circle" |
201				"message-square" |
202				"mic-off" |
203				"mic" |
204				"minimize-2" |
205				"minimize" |
206				"minus-circle" |
207				"minus-square" |
208				"minus" |
209				"monitor" |
210				"moon" |
211				"more-horizontal" |
212				"more-vertical" |
213				"move" |
214				"music" |
215				"navigation-2" |
216				"navigation" |
217				"octagon" |
218				"package" |
219				"paperclip" |
220				"pause-circle" |
221				"pause" |
222				"percent" |
223				"phone-call" |
224				"phone-forwarded" |
225				"phone-incoming" |
226				"phone-missed" |
227				"phone-off" |
228				"phone-outgoing" |
229				"phone" |
230				"pie-chart" |
231				"play-circle" |
232				"play" |
233				"plus-circle" |
234				"plus-square" |
235				"plus" |
236				"pocket" |
237				"power" |
238				"printer" |
239				"radio" |
240				"refresh-ccw" |
241				"refresh-cw" |
242				"repeat" |
243				"rewind" |
244				"rotate-ccw" |
245				"rotate-cw" |
246				"rss" |
247				"save" |
248				"scissors" |
249				"search" |
250				"send" |
251				"server" |
252				"settings" |
253				"share-2" |
254				"share" |
255				"shield-off" |
256				"shield" |
257				"shopping-bag" |
258				"shopping-cart" |
259				"shuffle" |
260				"sidebar" |
261				"skip-back" |
262				"skip-forward" |
263				"slash" |
264				"sliders" |
265				"smartphone" |
266				"speaker" |
267				"square" |
268				"star" |
269				"stop-circle" |
270				"sun" |
271				"sunrise" |
272				"sunset" |
273				"table" |
274				"tablet" |
275				"tag" |
276				"target" |
277				"terminal" |
278				"thermometer" |
279				"thumbs-down" |
280				"thumbs-up" |
281				"toggle-left" |
282				"toggle-right" |
283				"trash-2" |
284				"trash" |
285				"trending-down" |
286				"trending-up" |
287				"triangle" |
288				"truck" |
289				"tv" |
290				"type" |
291				"umbrella" |
292				"underline" |
293				"unlock" |
294				"upload-cloud" |
295				"upload" |
296				"user-check" |
297				"user-minus" |
298				"user-plus" |
299				"user-x" |
300				"user" |
301				"users" |
302				"video-off" |
303				"video" |
304				"voicemail" |
305				"volume-1" |
306				"volume-2" |
307				"volume-x" |
308				"volume" |
309				"watch" |
310				"wifi-off" |
311				"wifi" |
312				"wind" |
313				"x-circle" |
314				"x-square" |
315				"x" |
316				"zap-off" |
317				"zap" |
318				"zoom-in" |
319				"zoom-out"
320		})
321	})
322
323	// Output parameters allow you to declare data that an action sets. Actions that
324	// run later in a workflow can use the output data set in previously run
325	// actions. For example, if you had an action that performed the addition of
326	// two inputs (x + y = z), the action could output the sum (z) for other
327	// actions to use as an input.
328	// If you don't declare an output in your action metadata file, you can still
329	// set outputs and use them in a workflow.
330	#: "outputs-composite": close({
331
332		{
333			[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$"]: close({
334				// A string description of the output parameter.
335				"description"!: string
336
337				// The value that the output parameter will be mapped to. You can set this to a
338				// string or an expression with context. For example, you can use the steps
339				// context to set the value of an output to the output value of a step.
340				"value"!: string
341			})
342		}})
343
344	// Allows you to define conditions for the `post:` action execution. The `post:`
345	// action will only run if the conditions in `post-if` are met. If not set,
346	// then `post-if` defaults to `always()`.
347	#: "post-if": string
348
349	// Allows you to define conditions for the `pre:` action execution. The `pre:`
350	// action will only run if the conditions in `pre-if` are met. If not set, then
351	// `pre-if` defaults to `always()`. Note that the `step` context is
352	// unavailable, as no steps have run yet.
353	#: "pre-if": string
354
355	// Configures the path to the composite action, and the application used to execute the code.
356	#: "runs-composite": close({
357		// To use a composite run steps action, set this to 'composite'.
358		"using"!: "composite"
359
360		// The run steps that you plan to run in this action.
361		"steps"!: [...matchN(1, [{
362			"run"!:   _
363			"shell"!: _
364			...
365		}, {
366			"uses"!: _
367			...
368		}]) & close({
369			// The command you want to run. This can be inline or a script in your action repository.
370			"run"?: string
371
372			// The shell where you want to run the command.
373			"shell"?: matchN(>=1, [string, "bash" | "pwsh" | "python" | "sh" | "cmd" | "powershell"])
374
375			// Selects an action to run as part of a step in your job.
376			"uses"?: string
377
378			// A map of the input parameters defined by the action. Each input parameter is
379			// a key/value pair. Input parameters are set as environment variables. The
380			// variable is prefixed with INPUT_ and converted to upper case.
381			"with"?: {...}
382
383			// The name of the composite run step.
384			"name"?: string
385
386			// A unique identifier for the step. You can use the `id` to reference the step in contexts.
387			"id"?: string
388
389			// You can use the if conditional to prevent a step from running unless a
390			// condition is met. You can use any supported context and expression to create
391			// a conditional.
392			// Expressions in an if conditional do not require the ${{ }} syntax. However,
393			// you must always use the ${{ }} expression syntax or escape with '', "", or
394			// () when the expression starts with !, since ! is reserved notation in YAML
395			// format. For more information, see
396			// https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions
397			"if"?: string
398
399			// Sets a map of environment variables for only that step.
400			"env"?: matchN(1, [{[string]: bool | number | string}, #stringContainingExpressionSyntax])
401
402			// Prevents a job from failing when a step fails. Set to true to allow a job to
403			// pass when this step fails.
404			"continue-on-error"?: matchN(1, [bool, #expressionSyntax])
405
406			// Specifies the working directory where the command is run.
407			"working-directory"?: string
408		})]
409	})
410
411	// Configures the image used for the Docker action.
412	#: "runs-docker": close({
413		// You must set this value to 'docker'.
414		"using"!: "docker"
415
416		// The Docker image to use as the container to run the action. The value can be
417		// the Docker base image name, a local `Dockerfile` in your repository, or a
418		// public image in Docker Hub or another registry. To reference a `Dockerfile`
419		// local to your repository, use a path relative to your action metadata file.
420		// The `docker` application will execute this file.
421		"image"!: string
422
423		// Specifies a key/value map of environment variables to set in the container environment.
424		"env"?: matchN(1, [{[string]: bool | number | string}, #stringContainingExpressionSyntax])
425
426		// Overrides the Docker `ENTRYPOINT` in the `Dockerfile`, or sets it if one
427		// wasn't already specified. Use `entrypoint` when the `Dockerfile` does not
428		// specify an `ENTRYPOINT` or you want to override the `ENTRYPOINT`
429		// instruction. If you omit `entrypoint`, the commands you specify in the
430		// Docker `ENTRYPOINT` instruction will execute. The Docker `ENTRYPOINT
431		// instruction has a *shell* form and *exec* form. The Docker `ENTRYPOINT`
432		// documentation recommends using the *exec* form of the `ENTRYPOINT`
433		// instruction.
434		"entrypoint"?: string
435
436		// Allows you to run a script before the `entrypoint` action begins. For
437		// example, you can use `pre-entrypoint:` to run a prerequisite setup script.
438		// GitHub Actions uses `docker run` to launch this action, and runs the script
439		// inside a new container that uses the same base image. This means that the
440		// runtime state is different from the main `entrypoint` container, and any
441		// states you require must be accessed in either the workspace, `HOME`, or as a
442		// `STATE_` variable. The `pre-entrypoint:` action always runs by default but
443		// you can override this using `pre-if`.
444		"pre-entrypoint"?: string
445		"pre-if"?:         #."pre-if"
446
447		// Allows you to run a cleanup script once the `runs.entrypoint` action has
448		// completed. GitHub Actions uses `docker run` to launch this action. Because
449		// GitHub Actions runs the script inside a new container using the same base
450		// image, the runtime state is different from the main `entrypoint` container.
451		// You can access any state you need in either the workspace, `HOME`, or as a
452		// `STATE_` variable. The `post-entrypoint:` action always runs by default but
453		// you can override this using `post-if`.
454		"post-entrypoint"?: string
455		"post-if"?:         #."post-if"
456
457		// An array of strings that define the inputs for a Docker container. Inputs can
458		// include hardcoded strings. GitHub passes the `args` to the container's
459		// `ENTRYPOINT` when the container starts up.
460		// The `args` are used in place of the `CMD` instruction in a `Dockerfile`. If
461		// you use `CMD` in your `Dockerfile`, use the guidelines ordered by
462		// preference:
463		// - Document required arguments in the action's README and omit them from the `CMD` instruction.
464		// - Use defaults that allow using the action without specifying any `args`.
465		// - If the action exposes a `--help` flag, or something similar, use that to
466		// make your action self-documenting.
467		"args"?: [...string]
468	})
469
470	// Configures the path to the action's code and the application used to execute the code.
471	#: "runs-javascript": close({
472		// The application used to execute the code specified in `main`.
473		"using"!: "node12" | "node16" | "node20" | "node24"
474
475		// The file that contains your action code. The application specified in `using` executes this file.
476		"main"!: string
477
478		// Allows you to run a script at the start of a job, before the `main:` action
479		// begins. For example, you can use `pre:` to run a prerequisite setup script.
480		// The application specified with the `using` syntax will execute this file.
481		// The `pre:` action always runs by default but you can override this using
482		// `pre-if`.
483		"pre"?:    string
484		"pre-if"?: #."pre-if"
485
486		// Allows you to run a script at the end of a job, once the `main:` action has
487		// completed. For example, you can use `post:` to terminate certain processes
488		// or remove unneeded files. The application specified with the `using` syntax
489		// will execute this file. The `post:` action always runs by default but you
490		// can override this using `post-if`.
491		"post"?:    string
492		"post-if"?: #."post-if"
493	})
494
495	#expressionSyntax: =~"""
496		^\\$\\{\\{(.|[\r
497		])*\\}\\}$
498		"""
499
500	// Output parameters allow you to declare data that an action sets. Actions that
501	// run later in a workflow can use the output data set in previously run
502	// actions. For example, if you had an action that performed the addition of
503	// two inputs (x + y = z), the action could output the sum (z) for other
504	// actions to use as an input.
505	// If you don't declare an output in your action metadata file, you can still
506	// set outputs and use them in a workflow.
507	#outputs: close({
508
509		{
510			[=~"^[_a-zA-Z][a-zA-Z0-9_-]*$"]: close({
511				// A string description of the output parameter.
512				"description"!: string
513			})
514		}})
515
516	#stringContainingExpressionSyntax: =~"""
517		^.*\\$\\{\\{(.|[\r
518		])*\\}\\}.*$
519		"""
520}