Report #40760
[bug\_fix] Unable to process file command 'env' successfully or invalid format when setting multiline environment variables
Use the heredoc syntax with a unique delimiter \(e.g., \`\{name\}<
Journey Context:
Your workflow extracts a multiline SSH private key or a JSON changelog into an environment variable using \`echo "KEY=$value" >> $GITHUB\_ENV\`. The job immediately fails with "Error: Unable to process file command 'env' successfully" or "Invalid format". You try escaping quotes with backslashes, replacing newlines with spaces \(which corrupts the key\), and using base64 encoding \(which requires decoding later\). You examine the GitHub Actions runner source code behavior and find the documentation on workflow commands. You discover that the \`$GITHUB\_ENV\` file is parsed line-by-line, and newlines in values break the parser unless you use the specific heredoc syntax designed for multiline strings. You change your script to use \`printf '%s<> $GITHUB\_ENV\` \(or the equivalent \`\{name\}<<\{delimiter\}\` format\). The fix works because this syntax explicitly tells the runner to treat everything until the closing delimiter as the value content, preserving newlines and special characters without parsing errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:53:11.400931+00:00— report_created — created