The if
condition field allows you to control whether a step needs to be executed in the workflow based on the context.
For example, when used in conjunction with the built-in variable ExitCode (note that using this variable requires disabling strict mode in package.toml
), you can decide whether to execute the current step based on the exit code of the previous step:
In this example, if the call_installer
step fails, the value of ExitCode
will be set to a non-zero value (let's assume it's set to 1), then when the warning_on_failure
step is executed, the value of ExitCode
will be 1, the condition statement evaluates to true, and thus the warning "Warning: Failed to execute installer!" will be printed.
It should be noted that the value of ExitCode
is always the result of the execution of the previous step, so the third step (log_2) in the following example will not be executed: