GitHub Actions multiline GITHUB_OUTPUT broken without heredoc
Like GITHUB_ENV, the GITHUB_OUTPUT file needs a heredoc for multiline values. Writing key=value with embedded newlines truncates the output at the first newline or corrupts the file.
What this error means
A downstream steps.<id>.outputs.* reference contains only the first line, or the step fails parsing the output file.
github-actions
# Only the first line is captured without a heredoc:
echo "json=$(cat data.json)" >> "${GITHUB_OUTPUT}"Common causes
Multiline value without heredoc
Embedded newlines break the key=value line format of the output file.
Unescaped content in the value
Content resembling the file format can corrupt parsing.
How to fix it
Write multiline outputs with a heredoc
- Use KEY<<EOF ... EOF redirected to \${GITHUB_OUTPUT}.
- Pick a unique delimiter for untrusted content.
- Reference the output normally downstream.
.github/workflows/ci.yml
- id: gen
run: |
{
echo 'json<<EOF'
cat data.json
echo 'EOF'
} >> "${GITHUB_OUTPUT}"How to prevent it
- Use heredocs for all multiline outputs and env values.
- Validate downstream references receive the full value.
Related guides
GitHub Actions heredoc to GITHUB_ENV multiline failedFix a GitHub Actions multiline value written to GITHUB_ENV - a missing or value-colliding heredoc delimiter b…
GitHub Actions GITHUB_OUTPUT not set / set-output deprecatedFix GitHub Actions step outputs after set-output was removed - write to the GITHUB_OUTPUT file instead of the…
GitHub Actions fromJSON "Unexpected end of JSON input"Fix GitHub Actions fromJSON "Unexpected end of JSON input" - fromJSON received an empty or truncated string.