Skip to main content

Workflow definition syntax

A workflow definition decides the graph: which tasks a run starts, when each starts and stops, and on which compute type. The tasks themselves, apart from if and for_each tasks, come from task definitions, which decide the contract: the inputs a task takes, the outputs it gives, and the container it runs.

This page is the reference for the YAML format used to define workflows on Swale.

Annotated example​

Each comment says what the fields under it decide.

name: My data pipeline
description: Pulls raw data, processes it, and stores results.
# The compute type every task runs on, unless the task names its own
compute_type: cpu-4

# Values a run is started with, read as ${{inputs.<name>}}
inputs:
bucket_name:
default: my-default-bucket
mode:
default: fast

# The block a run starts in
entry_point: main

blocks:
main:
tasks:
fetch:
name: Fetch
# The task definition it runs, and values for its inputs
uses: my-account/fetch-[email protected]
args:
bucket: ${{inputs.bucket_name}}
process:
name: Process
uses: my-account/process-[email protected]
# This task's own compute type, in place of the workflow's
compute_type: a100-1
# Starts once fetch is Complete
start_on:
- fetch
args:
data: ${{tasks.fetch.outputs.result}}
router:
name: Router
start_on:
- process
# A control task: enters fast_output or slow_output
if:
condition: ${{inputs.mode == 'fast'}}
true: fast_output
false: slow_output

fast_output:
tasks:
save_fast:
name: Save fast
uses: my-account/save-[email protected]
args:
result: ${{tasks.process.outputs.data}}

slow_output:
tasks:
save_slow:
name: Save slow
uses: my-account/slow-save-[email protected]
args:
result: ${{tasks.process.outputs.data}}

Top-level fields​

FieldTypeRequiredDescription
namestringYesHuman-readable display name shown in the UI and CLI. See Workflow names for the rule it follows
descriptionstringNoOptional. Accepted so the file can describe itself; the platform does not store or show it
compute_typestringYesDefault compute type for every task unless a task overrides it: one of the compute types, such as cpu-4
inputsmapNoNamed inputs available as ${{inputs.name}} in expressions
blocksmapYesNamed blocks that organize the workflow tasks
entry_pointstringNoName of the block where execution starts. Defaults to main; the block it names must exist

The workflow-level compute_type, and each task's own where the task sets one, must name one of the compute types the platform offers, spelled exactly; a task that leaves its compute_type out, or blank, runs on the workflow-level one. Uploading or importing a workflow, or replacing its definition, is refused with 422 and an error naming any other value, and the workflow already registered is kept. Starting a run is refused the same way when the workflow names a type the platform has since stopped offering, so no run is created whose tasks could never be allocated compute.

Inputs​

Each key under inputs is a named input:

inputs:
my_input:
default: some_value
FieldTypeRequiredDescription
descriptionstringNoOptional description of the input
requiredbooleanNoIf true, the workflow fails to start when this input has no value. Defaults to false.
defaultstringNoValue used when the caller does not supply this input

Defaults are applied when the run is submitted, whatever started it — the API, the CLI, or the platform UI. The two fields interact as follows:

  • When the caller omits an input that declares a default, the default is recorded on the run as that input's value and ${{inputs.<name>}} resolves to it.
  • A value the caller supplies always wins over the default. For an input that is not required, that includes an explicitly empty value — omitting an input and passing it as empty are different requests.
  • A required input needs a value that is not empty or whitespace. Leaving it out uses its default, when that is not blank. Supplying it empty or as whitespace fails the start with a validation error naming the input, even when it declares a default.

Blocks​

Each key under blocks is a named block. A block contains a tasks map:

blocks:
my_block:
tasks:
task_a:
name: Task a
uses: account/task-name@version
FieldTypeRequiredDescription
tasksmapYesNamed task entries inside the block

Task properties​

Each key under tasks is the task's key: other tasks name it in start_on and terminate_on, and expressions read the task as tasks.<key>. The following properties are supported:

PropertyTypeRequiredDescription
namestringYesDisplay name for the task, shown in the UI, the Workflow Graph and the CLI.
usesstringYes*Task definition identifier in account/name@version format — see Task definition syntax for the version format. @version is optional: without it, uploading the workflow pins the most recently published version, and a newer one is picked up only when the workflow is uploaded or imported again. Required unless the task is a control task (if or for_each).
compute_typestringNoOverrides the workflow-level compute_type for this task: one of the compute types, such as a100-1
start_onlist of stringsNoKeys of tasks in the same block that must reach Complete before this task starts. A listed task that declares terminate_on only has to be executing. See Task dependencies.
terminate_onlist of stringsNoKeys of tasks in the same block that, once all of them finish without failing, stop this task and mark it Complete. See Task dependencies.
argsmapNoKey-value pairs passed as arguments to the task definition. Values may be expressions.
image_credentialsobjectNoUsername and password the platform signs in with to pull this task's image from a private registry. See Image credentials.
ifobjectNoMakes this an if task. See Control flow reference.
for_eachobjectNoMakes this a for_each task. See Control flow reference.

* A task needs uses unless it is a control task (if or for_each), which runs no image; see Upload checks and the Control flow reference.

Argument names are matched to the task definition's declared inputs case- and separator-insensitively — they resolve to the same INPUT_ variable (see Task definition syntax). An argument whose name matches no declared input is still passed through to the container, and the task's first execution-log entry records a warning naming it and listing the declared inputs.

Task dependencies​

Tasks inside a block can depend on other tasks in the same block through start_on and terminate_on, and a task can declare both.

start_on​

my_task:
name: My task
uses: my-account/my-[email protected]
start_on:
- earlier_task

start_on lists the tasks that must reach Complete before my_task starts. A task with no start_on is eligible to start as soon as the block is entered.

A task that declares its own terminate_on is the one exception: tasks that start_on it can begin as soon as it is executing, rather than when it completes. Such a task is meant to keep running alongside its dependents, and they reach it at its runner address, ${{tasks.<task_key>.ip-address}}.

terminate_on​

my_task:
name: My task
uses: my-account/my-[email protected]
terminate_on:
- other_task

terminate_on lists the tasks that, once all of them have finished without failing, cause my_task to be stopped. Every listed task must have reached Complete or Canceled; one of them finishing is not enough. Being stopped this way counts as a successful finish, so my_task ends Complete.

A task that declares terminate_on has no outputs or exports: what it writes to WORKFLOW_TASK_OUTPUT and WORKFLOW_ENV is discarded. See Tasks that declare terminate_on.

Task dependencies in the lifecycle reference says what each does to a task's status.

Upload checks​

Uploading or importing a workflow also enforces these rules, and refuses the whole file when one is broken:

  • Every key must be one this page lists. A misspelled or unknown key makes the file invalid, and the error gives the key's line, column and name.
  • Task keys must be unique across the whole workflow, not only within their block.
  • start_on and terminate_on name tasks in the same block. A task cannot list itself, cannot list the same task in both, and the dependencies cannot form a cycle.
  • Each uses must name a task definition that exists and that the account can use.
  • An if or for_each task cannot declare uses, args or image_credentials, and a task cannot declare both if and for_each.
  • No two args of one task can name the same input. Because names are matched ignoring letter case and treating - and _ as the same, file-path and FILE_PATH are one input.
  • Every ${{...}} expression in a task's args, if condition, for_each items and image_credentials must parse, and may call only the expression functions, each with the number of arguments it takes. The error names the task, its block, the value and what is wrong, as in Task 'build' in block 'main': Argument 'message' could not be parsed: Unexpected end of expression.
  • No expression can read tasks.<task_key>.outputs, whole or one output of it, for a task that declares terminate_on, because such a task has none. Its address, ${{tasks.<task_key>.ip-address}}, can be read.

A task definition can stop being available after the workflow is uploaded, when its owner deletes it or the version the workflow uses, or makes it private. Runs of the workflow are then refused at start or fail; see Task definitions that are no longer available.

Image credentials​

When the image a task definition names is on a private registry, the task in the workflow gives the username and password to pull it with:

tasks:
build:
name: Build
uses: my-account/build-[email protected]
image_credentials:
username: ${{secrets.REGISTRY_USERNAME}}
password: ${{secrets.REGISTRY_TOKEN}}
FieldTypeRequiredDescription
usernamestringYesThe username the registry expects. Keep it in a secret too, as in the example.
passwordstringYesThe password or access token that goes with it. Keep it in a secret and reference it with an expression, as in the example.
  • A task that declares image_credentials must give both values. Only a task with uses can declare them; see Upload checks.
  • Both values are resolved when the task starts, the same way args are, so a secret's current value is the one used. Changing or deleting the secret later does not affect a task that has already started.
  • If either value resolves to nothing — for example, because it names a secret the project cannot use — the task moves to Failed without a container being scheduled, and the first execution-log entry names the empty value.
  • The username and password are used only to pull that image, signing in to the registry the task definition's image names. They are not passed to the task's container as an argument, an environment variable or a file.
  • When a task declares image_credentials, its image is always pulled signed in with them. If the registry refuses them, the image cannot be pulled and the task fails, even when the image is public.
  • The first execution-log entry lists the credentials under the image. The password is always shown as ***, and a username that came from a secret is masked like any other secret value.

See Use a task image from a private registry for the full steps.