fix(ci): use printf for safe JSON handling with special characters

Issue: Secrets with special characters (SSH_PRIVATE_KEY) breaking shell
Error: "command not found" due to shell interpreting secret values

Root Cause: echo interprets escape sequences and special characters
Fix: Use printf '%s' for literal string output

Changes:
- Replace echo with printf '%s' for safe JSON handling
- Filter out github_token (not needed in .env)
- Multi-line jq for better readability

This fixes multiline secrets (SSH keys, certificates, etc.)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-04 16:28:10 -05:00
parent 3322e6079a
commit a7f3aadef9

View File

@ -14,8 +14,12 @@ runs:
run: |
echo "TESTING=true" > .env
# Parse JSON secrets and write to .env
echo '${{ inputs.secrets }}' | jq -r 'to_entries[] | "\(.key)=\(.value)"' >> .env
# Use printf to safely handle JSON with special characters
printf '%s' '${{ inputs.secrets }}' | jq -r '
to_entries[] |
select(.key != "github_token") |
"\(.key)=\(.value)"
' >> .env
echo "✅ Generated .env with $(wc -l < .env) environment variables"