GitHub Actions "Unable to process file command env" (multiline secret to GITHUB_ENV)
Writing to GITHUB_ENV uses NAME=value lines. A value containing newlines (a PEM key, a multiline secret) breaks that format and must use the heredoc syntax instead.
What this error means
A run step appending a multiline value to GITHUB_ENV fails with "Unable to process file command 'env' successfully", typically when the value is a multiline secret.
Error: Unable to process file command 'env' successfully.
Error: Invalid format '-----BEGIN PRIVATE KEY-----'Common causes
Multiline value without a delimiter
A value with embedded newlines was written as NAME=value, so the lines after the first are treated as malformed commands.
Secret with newlines piped directly
A multiline secret was echoed straight into GITHUB_ENV without heredoc framing.
How to fix it
Use heredoc syntax for multiline env values
- Write the value with a unique heredoc delimiter.
- Ensure the delimiter does not appear inside the value.
- Prefer passing secrets via env: on the step when possible.
- run: |
{
echo "PRIVATE_KEY<<EOF"
echo "${{ secrets.PRIVATE_KEY }}"
echo "EOF"
} >> "${GITHUB_ENV}"How to prevent it
- Always use heredoc framing for multiline GITHUB_ENV values.
- Pick a delimiter guaranteed not to appear in the value.
- Pass secrets through step-level env where you can.