dotenv-vault icon indicating copy to clipboard operation
dotenv-vault copied to clipboard

generate .env file in github actions

Open naorye opened this issue 3 years ago • 1 comments

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?

naorye avatar Jan 31 '23 20:01 naorye

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

nahueloyha avatar Apr 16 '23 03:04 nahueloyha