Skip to content
Latchkey

GitHub Actions GITHUB_ENV heredoc delimiter appears in the value

The heredoc delimiter you used to write a multiline value to GITHUB_ENV also occurs inside the content, so the runner closes the block early and the rest of the value leaks as malformed lines.

What this error means

A multiline GITHUB_ENV write fails or yields a truncated variable because the chosen delimiter collided with the value.

github-actions
Error: Unable to process file command 'env' successfully.
Error: Matching delimiter not found 'EOF'

Common causes

Common delimiter inside the value

A predictable delimiter like EOF appears in logs or text being written, so the heredoc closes at the wrong place.

How to fix it

Use a random, unguessable delimiter

  1. Generate a unique delimiter per write and reuse it for open and close.
  2. Ensure the delimiter cannot appear in the content.
  3. Re-run.
.github/workflows/ci.yml
- run: |
    DELIM="EOF_$(openssl rand -hex 8)"
    {
      echo "BODY<<${DELIM}"
      cat report.txt
      echo "${DELIM}"
    } >> "${GITHUB_ENV}"

How to prevent it

  • Always randomize heredoc delimiters when the content is untrusted.
  • Never use a static EOF for values derived from logs or user input.

Related guides

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