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
args:
bucket: ${{inputs.bucket_name}}
process:
name: Process
# 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
args:
result: ${{tasks.process.outputs.data}}
slow_output:
tasks:
save_slow:
name: Save slow
args:
result: ${{tasks.process.outputs.data}}
Top-level fields
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Human-readable display name shown in the UI and CLI. See Workflow names for the rule it follows |
description | string | No | Optional. Accepted so the file can describe itself; the platform does not store or show it |
compute_type | string | Yes | Default compute type for every task unless a task overrides it: one of the compute types, such as cpu-4 |
inputs | map | No | Named inputs available as ${{inputs.name}} in expressions |
blocks | map | Yes | Named blocks that organize the workflow tasks |
entry_point | string | No | Name 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
| Field | Type | Required | Description |
|---|---|---|---|
description | string | No | Optional description of the input |
required | boolean | No | If true, the workflow fails to start when this input has no value. Defaults to false. |
default | string | No | Value 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 notrequired, that includes an explicitly empty value — omitting an input and passing it as empty are different requests. - A
requiredinput needs a value that is not empty or whitespace. Leaving it out uses itsdefault, 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 adefault.
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
| Field | Type | Required | Description |
|---|---|---|---|
tasks | map | Yes | Named 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:
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for the task, shown in the UI, the Workflow Graph and the CLI. |
uses | string | Yes* | 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_type | string | No | Overrides the workflow-level compute_type for this task: one of the compute types, such as a100-1 |
start_on | list of strings | No | Keys 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_on | list of strings | No | Keys of tasks in the same block that, once all of them finish without failing, stop this task and mark it Complete. See Task dependencies. |
args | map | No | Key-value pairs passed as arguments to the task definition. Values may be expressions. |
image_credentials | object | No | Username and password the platform signs in with to pull this task's image from a private registry. See Image credentials. |
if | object | No | Makes this an if task. See Control flow reference. |
for_each | object | No | Makes 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
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
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_onandterminate_onname 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
usesmust name a task definition that exists and that the account can use. - An
iforfor_eachtask cannot declareuses,argsorimage_credentials, and a task cannot declare bothifandfor_each. - No two
argsof one task can name the same input. Because names are matched ignoring letter case and treating-and_as the same,file-pathandFILE_PATHare one input. - Every
${{...}}expression in a task'sargs,ifcondition,for_eachitems andimage_credentialsmust 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 inTask '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 declaresterminate_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
image_credentials:
username: ${{secrets.REGISTRY_USERNAME}}
password: ${{secrets.REGISTRY_TOKEN}}
| Field | Type | Required | Description |
|---|---|---|---|
username | string | Yes | The username the registry expects. Keep it in a secret too, as in the example. |
password | string | Yes | The 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_credentialsmust give both values. Only a task withusescan declare them; see Upload checks. - Both values are resolved when the task starts, the same way
argsare, 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
Failedwithout 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.