DOC_INDEX
THEME
DOCS/Example Cookbook/Execution Basics Examples

Execution Basics Examples

OrchStep examples for basic workflow execution


hello world

Hello World

# Example: Hello World
# The simplest OrchStep workflow -- one task, one step.
# This is the starting point for learning OrchStep.
#
# Try: orchstep run

name: hello-world
desc: "Your first OrchStep workflow"

tasks:
  main:
    desc: "Say hello"
    steps:
      - name: greet
        desc: "Output a greeting using the shell function"
        func: shell
        do: echo 'Hello from OrchStep!'

shell commands

Shell Commands

# Example: Shell Commands
# Shows the two ways to run shell commands in OrchStep:
#   1. Using "do:" -- the concise shorthand for shell execution
#   2. Using "args: cmd:" -- the explicit form
#
# Both approaches use func: shell under the hood.
# The "do:" shorthand is recommended for readability.
#
# Try: orchstep run

name: shell-commands
desc: "Different ways to execute shell commands"

tasks:
  main:
    desc: "Demonstrate shell command patterns"
    steps:
      # Pattern 1: "do:" shorthand (recommended)
      - name: using_do_shorthand
        desc: "Run a shell command using 'do:' syntax"
        func: shell
        do: "echo 'This uses the do: shorthand'"

      # Pattern 2: "args: cmd:" explicit form
      - name: using_args_cmd
        desc: "Run a shell command using explicit 'args: cmd:' syntax"
        func: shell
        args:
          cmd: "echo 'This uses the args:cmd: form'"

      # Pattern 3: Multi-line shell script with "do:"
      - name: multi_line_script
        desc: "Run a multi-line shell script"
        func: shell
        do: |
          echo "Step 1: Checking environment..."
          echo "Step 2: Running build..."
          echo "Step 3: Build complete!"

      # Pattern 4: Capture output for later steps
      - name: capture_output
        desc: "Run a command and capture its output"
        func: shell
        do: echo "build-artifact-v1.0.0"
        outputs:
          artifact_name: "{{ result.output }}"

      - name: use_captured_output
        desc: "Reference the captured output from a previous step"
        func: shell
        do: echo "Deploying artifact -- {{ steps.capture_output.artifact_name }}"

shell with timeout

Shell with Timeout

# Example: Shell with Timeout
# Shows how to pass additional parameters to shell commands.
# The "args:" block lets you set options like timeout alongside "do:".
#
# Try: orchstep run

name: shell-with-timeout
desc: "Shell commands with additional parameters"

tasks:
  main:
    desc: "Run commands with timeout and other options"
    steps:
      - name: quick_command
        desc: "A fast command with a generous timeout"
        func: shell
        do: echo 'This completes well within 30 seconds'
        args:
          timeout: 30

      - name: health_check
        desc: "Simulate a health check with a short timeout"
        func: shell
        do: |
          echo "Checking service health..."
          echo "Status: healthy"
        args:
          timeout: 10