Skip to content
Latchkey

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

  1. Use KEY<<EOF ... EOF redirected to \${GITHUB_OUTPUT}.
  2. Pick a unique delimiter for untrusted content.
  3. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →