Reputation: 11
So I have in github repository secret, a variable prod_env_file
where I store my entire .env keys and values into. I am trying to generate a .env in gh actions to pull in the prod_env_file
. Here is a example .yml code:
env:
PROD_ENV_FILE: ${{ secrets.PROD_ENV_FILE }}
steps:
- name: Configure Env
run: |
touch .env
echo $PROD_ENV_FILE >> .env
However, my entire prod_env_file just goes in as a single liner. Accessing the process.env.FIRST_ENV_VARIABLE
ends up containing the entire rest of prod_env_file. Is there a way to fix this? Thanks!
Upvotes: 1
Views: 1391
Reputation: 3551
You need to identify how your environment variables are split.
If they are divided by a space, like this:
SECRET1=1 SECRET2=2 SECRET3=3
You can simple replace the spaces with a new line using the tr command:
echo "SECRET1=1 SECRET2=2 SECRET3=3" | tr " " "\n" >> .env
Within your Github Actions workflow would be:
echo $PROD_ENV_FILE | tr " " "\n" >> .env
And that will save the .env
file as:
SECRET1=1
SECRET2=2
SECRET3=3
Upvotes: 1