Skip to content
Latchkey

GitHub Actions Multiline GITHUB_OUTPUT / GITHUB_ENV "Invalid format"

Writing a value containing newlines to GITHUB_OUTPUT or GITHUB_ENV with the simple name=value form breaks, because each line after the first is parsed as its own bad entry. Multiline values need the delimiter (heredoc) form.

What this error means

A step that writes a multiline value fails with "Invalid format" / "Unable to process file command", or downstream reads only the first line of the value.

Actions log
Error: Unable to process file command 'output' successfully.
Error: Invalid format 'second line of the value'

Common causes

Multiline value with name=value

The name=value form only supports single-line values. A value with embedded newlines makes every line after the first an invalid file command.

Unescaped delimiter collision

When using the heredoc form, a value that itself contains the chosen delimiter token breaks the block. The delimiter must be unique.

How to fix it

Use the heredoc delimiter syntax

Write name<<DELIM, the value, then DELIM on its own line. Use a random, unlikely delimiter.

.github/workflows/ci.yml
- run: |
    {
      echo "notes<<EOF"
      echo "line one"
      echo "line two"
      echo "EOF"
    } >> "$GITHUB_OUTPUT"

Make the delimiter unique

  1. Pick a delimiter that cannot appear in the value, for example a random token.
  2. Generate one with DELIM=$(uuidgen) and use it in the heredoc.
  3. Apply the same pattern for multiline GITHUB_ENV and GITHUB_STEP_SUMMARY writes.

How to prevent it

  • Always use the heredoc form for any value that may contain newlines.
  • Use a random, unique delimiter token to avoid collisions.
  • Quote the file path as "$GITHUB_OUTPUT" to be safe with spaces.

Related guides

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