Steps

Steps are the individual commands or actions within a job.

Steps can be defined using either steps: (GitHub Actions style) or cmds: (Taskfile style). Both are interchangeable.

String Shorthand

Steps can be written as bare strings without run: or cmd: prefix:

  steps:
  - echo "hello"          # bare string
  - run: echo "hello"     # equivalent explicit form
  - cmd: echo "hello"     # also equivalent

Properties

Field Type Default Description
name string - Step name for display
desc string - Step description (shown in output)
run string - Command to execute
cmd string - Alias for run
cmds list - Multiple commands to run in sequence
task string - Task/job to invoke
if string - Conditional execution
for string - Loop iteration
vars map {} Step-level variables
env object - Step environment
include string/list - Include external files
dir string - Working directory
deferred bool false Run on cleanup (like Go defer)
defer string/obj - Deferred step (shorthand or object)
detach bool false Run in background
tty bool false Allocate PTY (enables colors)
interactive bool false Stream output live, connect stdin
verbose bool false Show output
summarize bool false Summarize output
quiet bool false Suppress output
passthru bool false Print output with tree indentation

Basic Steps

  name: Basic Steps

jobs:
  example:
    aliases: [default]
    steps:
      - run: echo "First step"
      - run: echo "Second step"
      - run: echo "Third step"

Named Steps

  name: Named Steps

jobs:
  deploy:
    aliases: [default]
    steps:
      - name: Prepare
        run: echo "Preparing deployment"

      - name: Deploy
        run: echo "Deploying application"

      - name: Verify
        run: echo "Verifying deployment"

Task Invocation

Call other jobs using task: :

  name: Task Invocation

jobs:
  default:
    steps:
      - task: prepare
      - task: build
      - task: verify

  prepare:
    steps:
      - run: echo "Preparing..."

  build:
    steps:
      - run: echo "Building..."

  verify:
    steps:
      - run: echo "Verifying..."

Deferred Steps

Steps run after the job completes (like defer in Go). Two syntax options:

Using deferred: true :

  steps:
  - run: cleanup.sh
    deferred: true

Using defer: wrapper:

  steps:
  - defer: cleanup.sh
  name: Deferred Steps

jobs:
  with-cleanup:
    aliases: [default]
    steps:
      - name: Cleanup (runs last)
        deferred: true
        run: echo "Cleaning up resources"

      - name: Setup
        run: echo "Setting up"

      - name: Work
        run: echo "Doing work"

For Loops

Iterate over lists with for: :

  name: For Loops

vars:
  platforms:
    - linux
    - darwin
    - windows

jobs:
  build:
    aliases: [default]
    steps:
      - for: platform in platforms
        run: echo "Building for ${{ platform }}"

Conditional Steps

Execute steps conditionally using if :

  name: Conditional Steps

vars:
  verbose: true
  deploy: false

jobs:
  example:
    aliases: [default]
    steps:
      - run: echo "Always runs"

      - if: verbose == true
        run: echo "Verbose output enabled"

      - if: deploy == true
        run: echo "This is skipped"

Step Environment

Override environment for a single step:

  name: Step Environment

jobs:
  build:
    aliases: [default]
    steps:
      - name: Linux build
        env:
          vars:
            GOOS: linux
            GOARCH: amd64
        run: echo "Building for $GOOS/$GOARCH"

      - name: Darwin build
        env:
          vars:
            GOOS: darwin
            GOARCH: arm64
        run: echo "Building for $GOOS/$GOARCH"

See Also