Workflow definition

A workflow is a YAML file that describes the connections between events and tasks of services with a step-by-step system.

It is structured in the following way:

KeyTypeDescription
nameStringName of the workflow
stepsStep[]Steps to execute (trigger, filter or task)

A workflow has a list of steps. Each step indicates a specific action to do. There is three types of steps:

Trigger

An event that will trigger the workflow.

  • Should be the first step of the workflow.
  • Only one trigger is possible per workflow.
  • It triggers the workflow when a matching event is emitted.

Triggers available:

Task

Defines the task to execute of a given instance of a service.

  • A workflow should have at least one task and can have as many as you want.

Tasks available:

Filter

Stop the execution of the workflow if a condition doesn't match. Apply one or multiple conditions on the previous step's outputs. All conditions should match to continue to the next step.

  • A workflow can have as many filters as you want.
  • Filters are optional.
KeyTypeDescription
type"filter"
conditionsmap<string, Value>Key-value map where the key references a data of the previous step's outputs and the value is the expected matching value

The simplest way to set conditions is to use a map<string, Value> where the key references a data of the previous step's outputs and the value is the expected matching value.

The condition value can be any of the following types:

  • string
  • bool
  • number

Example

workflow.yml
- type: filter
  conditions:
    previousTaskOutput_1: "hello" # the value of this output must be "hello"
    previousTaskOutput_2: 10 # the value of this output must be 10
    previousTaskOutput_3: true # the value of this output must be true

Advanced filter

You can create advanced filters with different predicate and references. Check out the filter documentation.

Example

Here is an example of typical workflow.

workflow.yml
name: hello-world
steps:
  - type: trigger
    endpointKey: helloWorld
  - type: task
    handler: ./hello-world.js

Environmental variable

You can override any value in the workflow file during the compilation by using the following syntax:

$(env:XXXX)

Where XXXX is the name of the environmental variable defined in your .env file or given with a flag on the workflow:dev command.