Skip to content

Add conditional step execution in YAML workflows #5

Description

@tombee

Problem

YAML workflows currently execute all defined steps unconditionally. Real workflows need branching logic based on step results or inputs.

Concrete example from foreman: The implementing stage should skip test running if no test files exist, or branch to different strategies based on codebase type.

Proposal

Add conditional execution support:

steps:
  - id: check_tests
    shell.run: "test -d tests && echo 'has_tests' || echo 'no_tests'"
    
  - id: run_tests
    if: "{{.steps.check_tests.stdout}} == 'has_tests'"
    shell.run: "npm test"
    
  - id: skip_message
    if: "{{.steps.check_tests.stdout}} == 'no_tests'"
    type: llm
    prompt: "No tests to run, proceeding with implementation"

General Utility

  1. Conditional workflows - Branch based on analysis results
  2. Error handling - Skip subsequent steps if earlier step fails
  3. Feature detection - Adapt workflow to environment capabilities

Acceptance Criteria

  • if field on steps for conditional execution
  • Template expressions evaluate to boolean
  • Falsy conditions skip step (not error)
  • Skipped step outputs are empty/null
  • Support comparison operators (==, !=, contains)
  • Integration test for conditional branching

Priority

Medium - Improves workflow flexibility, not blocking for MVP.

Labels

enhancement, sdk, priority:medium

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions