Conditional steps allow the definition of tasks that only run if a condition is met.

A conditional step consists of a step with a key when. The purpose of the when step is customizing commands and job configuration to run on custom conditions (determined at compile time) that are checked before a workflow runs.

Example





 

tasks:
    build-image:
        type: build
        ...
        when: branch == 'master'

The expression has access to the workflow related context objects branch, tag, platform and event.

You can provide more complex expression using operators and modifiers

branch == 'master'
branch in ('master', 'staging') || branch =~ /hotfix/ || tag
event == 'deployment'
platform == 'linux/amd64'