Skip to main content

How expressions work

A ${{...}} expression is a piece of logic inside a YAML string value, which the platform replaces with its result when the task that holds it starts. Expressions read run inputs, secrets, environment variables, loop items and the outputs of the finished tasks that task waits on, always as text.

args:
message: ${{inputs.greeting}}
label: ${{format('Run {0}', inputs.run_number)}}

Text outside the delimiters passes through unchanged. Expression language lists everything an expression can read and every operator, and Expression functions the functions.

Resolution timing​

Expressions are resolved when each task starts, not when the workflow definition is uploaded or when the run starts. Each task sees the run as it stands at that moment:

  • ${{inputs.*}} reads the values the run was started with, defaults included.
  • ${{secrets.*}} reads each secret's value at the moment the task starts, so a secret changed during a run reaches the tasks that start after the change.
  • ${{tasks.<task_key>.outputs.*}} reads another task's output only once that task has finished, and only when this task waits on it through start_on; see Task outputs.

A reference that has nothing to read when the task starts, such as an output of a task this task does not wait on, gives null, which becomes an empty string. The task still starts: an expression fails a task only when it cannot be evaluated at all, as when fromJSON is given text that is not JSON. An expression with a syntax error, or one that calls a function that does not exist or with the wrong number of arguments, is refused when the workflow or task definition holding it is uploaded or imported.

Values are text​

Every value an expression reads is text, whichever namespace it comes from. Inputs are typed into a form or passed on a command line, outputs are written as key=value lines to a file, and secrets and environment variables are strings, so there is nothing to carry a type.

That shapes comparisons. An input set to true holds the text true, so compare it with 'true': comparing the text true with the boolean true compares them as numbers, and gives false. An output holding a JSON array or object stays a string until you read it with fromJSON, after which you can index into it.

It also shapes truthiness. Because an input that someone set to false or 0 arrives as the text 'false' or '0', those strings are falsy, as are the empty string and 'NaN', so a condition such as ${{inputs.dry_run}} behaves the way the person who set the input meant. Every other string is truthy, including 'no' and 'off'.

Next steps​