3 ms·
Maybe this thread is the right place to ask a usage question: I have a multiline GitHub Secret which I would like to print out to a `.env` file in a GitHub Acti
by cstuder 5y ago
Maybe this thread is the right place to ask a usage question: I have a multiline GitHub Secret which I would like to print out to a `.env` file in a GitHub Action. How can I do that?
My current solution doesn't support spaces within the secret content:
- name: Write .env
run: |
echo $ENV_FILE | tr ' ' '\n' > .env
shell: bash
env:
ENV_FILE: ${{secrets.DOTENV}}
Writing a multiline secret string directly into a file replaces all newlines with spaces. The `tr` command converts them back to newlines.
- nagisa 5y ago`echo "$ENV_FILE"`, maybe? `echo $ENV_FILE` (without quotes) will split the environment variable by separators in $IFS and pass each chunk as separate argument.
- xyzzy_plugh 5y agoYou have to quote your variable expansion. Also using echo is bad form, instead try cat <<<$ENV_FILE >.env