Steps

To create a workflow, you define the steps you want and their order of execution using the Workflows syntax. Every workflow must have at least one step.

By default, Workflows treats steps as if they are in an ordered list and executes them one at a time until all the steps have run. For example, this workflow has two steps:

YAML

  - STEP_NAME_A:
      ...
  - STEP_NAME_B:
      ...
  

JSON

  [
    {
      "STEP_NAME_A": {
        ...
      }
    },
    {
      "STEP_NAME_B": {
        ...
      }
    },
  ]
    

Step names

Workflows doesn't enforce a naming convention for step names. However, we recommend consistent usage such as creating step names that only include alphanumeric characters and underscores.

Step types

Workflows supports various types of steps, including the following:

Implicit step ordering

This sample shows implicit step ordering within a workflow. By default, the steps of a workflow are executed in the order they appear in the workflow definition.

YAML

- first_step:
    call: http.get
    args:
      url: https://www.example.com/callA
- second_step:
    call: http.get
    args:
      url: https://www.example.com/callB
- third_step:
    call: http.get
    args:
      url: https://www.example.com/callC

JSON

[
  {
    "first_step": {
      "call": "http.get",
      "args": {
        "url": "https://www.example.com/callA"
      }
    }
  },
  {
    "second_step": {
      "call": "http.get",
      "args": {
        "url": "https://www.example.com/callB"
      }
    }
  },
  {
    "third_step": {
      "call": "http.get",
      "args": {
        "url": "https://www.example.com/callC"
      }
    }
  }
]

Nested steps

You can use a steps block to nest a series of steps and further define a workflow:

YAML

  - STEP_NAME:
    steps:
      - STEP_NAME_1:
          steps:
              - STEP_NAME_A:
                  ...
              - STEP_NAME_B:
                  ...
      - STEP_NAME_2:
          steps:
              - STEP_NAME_C:
                  ...
  

JSON

    {
      STEP_NAME: {
      "steps": [
        {
          STEP_NAME_1: {
            "steps": [
              {
                STEP_NAME_A:
                  ...
              },
              {
                STEP_NAME_B:
                  ...
              }
            ]
          }
        },
        {
          STEP_NAME_2: {
            "steps": [
              {
                STEP_NAME_C:
                  ...
              }
            ]
          }
        }
      ]
    }
  }
    

Variables declared in a steps block have workflow-level scope and can be accessed outside of the block. Any step type can be nested inside of a steps block including assign, call, and switch. For example:

YAML

  main:
      steps:
      - series_one:
          steps:
              - step_a:
                  call: http.get
                  args:
                      url: https://host.com/api1
                  result: api_response1
              - step_b:
                  assign:
                      - varA: "Monday"
                      - varB: "Tuesday"
      - series_two:
          steps:
              - step_c:
                  call: http.get
                  args:
                      url: https://host.com/api2
                  result: api_response2
              - step_d:
                  assign:
                      - varC: "Wednesday"
                      - varD: "Thursday"
  

JSON

  {
    "main": {
      "steps": [
        {
          "series_one": {
            "steps": [
              {
                "step_a": {
                  "call": "http.get",
                  "args": {
                    "url": "https://host.com/api1"
                  },
                  "result": "api_response1"
                }
              },
              {
                "step_b": {
                  "assign": [
                    {
                      "varA": "Monday"
                    },
                    {
                      "varB": "Tuesday"
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "series_two": {
            "steps": [
              {
                "step_c": {
                  "call": "http.get",
                  "args": {
                    "url": "https://host.com/api2"
                  },
                  "result": "api_response2"
                }
              },
              {
                "step_d": {
                  "assign": [
                    {
                      "varC": "Wednesday"
                    },
                    {
                      "varD": "Thursday"
                    }
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  }
    

Note that in some cases, steps is required; for example, when defining a subworkflow or a for loop.