GitHub Actions heredoc to GITHUB_ENV multiline failed
Writing a multiline value to \${GITHUB_ENV} requires a heredoc with a unique delimiter. A missing delimiter, or one that appears inside the value, corrupts the environment-file format and fails the step.
What this error means
A step writing a multiline env var fails parsing the environment file, or downstream steps see a truncated/garbled value.
Error: Invalid format ' "nested": true,'
while reading GITHUB_ENVCommon causes
Missing heredoc delimiter
Writing key=multiline value without a heredoc breaks the env-file parser.
Delimiter collides with the value
If the chosen delimiter appears in the content, the block terminates early.
How to fix it
Use a unique heredoc delimiter
- Wrap the value in KEY<<DELIM ... DELIM with a delimiter not present in the content.
- Use a random/unique delimiter for untrusted content.
- Apply the same pattern for GITHUB_OUTPUT multiline values.
- run: |
{
echo 'CONFIG<<EOF'
cat config.json
echo 'EOF'
} >> "${GITHUB_ENV}"How to prevent it
- Always use heredoc delimiters for multiline GITHUB_ENV/GITHUB_OUTPUT writes.
- Choose delimiters that cannot appear in the value.