generate .env file in github actions
I am trying to integrate dotenv with my deployment process.
I am using Github actions to build the app and as part of the build process I generate app.yaml file from app.yaml.template:
- id: prepare-app-yaml
uses: mshick/fast-envsubst@v1
with:
env-file: app/.env
in-file: app/app.yaml.template
out-file: app/app.yaml
The generation process required env vars. Before dotenv I used the following command to generate .env file:
- id: generate-dotenv-file
env:
DOTENV_CONTENT: ${{ secrets.DOTENV_CONTENT }}
run: echo "$DOTENV_CONTENT" > app/.env
Now I am trying to generate the .env file using dotenv but there is no way to do it using the DOTENV_KEY only. I don't want to add DOTENV_ME var because that way my CI will have both DOTENV_ME and DOTENV_KEY (which is used by the application runtime).
Its there a way to write .env file?
It seems there is no official way yet, but you could use the local-decrypt command to fetch / generate your .env file:
npx dotenv-vault local decrypt $DOTENV_KEY > .env