GitHub Actions multiline run script fails (YAML block scalar)
By Kaveh Alemi·Latchkey
Multiline run commands use a YAML block scalar (| keeps newlines, > folds them). Choosing > or mis-indenting lines folds or strips your script so the shell sees a different command than intended.
What this error means
A multiline run command behaves as one folded line, loses newlines, or fails with a shell syntax error after the YAML block scalar mangled it.
github-actions
# Using '>' folds newlines into spaces, breaking the script:
run: >
echo one
echo two # becomes: echo one echo two
Common causes
Folded scalar (>) used for a script
> joins lines with spaces, collapsing separate commands into one.
Inconsistent indentation in the block
Mismatched indentation truncates or reshapes the script body.
How to fix it
Use the literal block scalar
Use | (literal) to preserve newlines for multiline scripts.
Indent every line of the block consistently under run.
Reserve > for prose-like folding, not shell commands.
.github/workflows/ci.yml
- run:|echo oneecho two./build.sh
How to prevent it
Default to | for multiline run blocks.
Lint workflows so folded-scalar mistakes are caught.
Frequently asked questions
What causes "multiline run script fails"?
> joins lines with spaces, collapsing separate commands into one.