Advanced Examples

Running sub workflows

Organize complex workflows using sub workflow:

steps:
  - name: sub workflow
    run: sub_workflow
    params: "FOO=BAR"

The result of the sub workflow will be available from the standard output of the sub workflow in JSON format.

Example:

{
  "name": "sub_workflow"
  "params": "FOO=BAR",
  "outputs": {
    "RESULT": "ok",
  }
}

You can access the output of the sub workflow using the output field:

steps:
  - name: sub workflow
    run: sub_workflow
    params: "FOO=BAR"
    output: SUB_RESULT

  - name: use sub workflow output
    command: echo $SUB_RESULT
    depends:
      - sub workflow

Command Substitution

Use command output in configurations:

env:
  TODAY: "`date '+%Y%m%d'`"
steps:
  - name: use date
    command: "echo hello, today is ${TODAY}"

Lifecycle Hooks

React to DAG state changes:

handlerOn:
  success:
    command: echo "succeeded!"
  cancel:
    command: echo "cancelled!"
  failure:
    command: echo "failed!"
  exit:
    command: echo "exited!"
steps:
  - name: main task
    command: echo hello

Repeat Steps

Execute steps periodically:

steps:
  - name: repeating task
    command: main.sh
    repeatPolicy:
      repeat: true
      intervalSec: 60