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

[feature request] adhere to dotenv common behaviour

Open FranciscoKloganB opened this issue 9 months ago • 1 comments

As a user I want the action not to fail When the .env file that was specified does not exist Because this is the way dotenv extensions, plugins and NPM packages usually work

To avoid breaking changes this could be an input.fail-on-not-found or something.

Thanks! :)

FranciscoKloganB avatar May 01 '24 22:05 FranciscoKloganB

I'm not sure how useful this is with regards to this GH action as the whole purpose is to apply environmental variables via the env file for build purposes. Can you elaborate in which situation you add this action but not an env file?

falti avatar May 02 '24 09:05 falti

We have a situation where we use a template repository as the basis for developing applications and libraries. We include several workflows to assist with code scanning, building, testing, and packaging. Some applications or libraries may use .env files while others may not. This enhancement would allow us to include this Action in our boilerplate code so that those apps/libs that do have .env files will work as expected while those that do not have .env files will also work as expected - all without requiring the developer to customize our standard build/test/package process.

jeffstoner-scilo avatar May 15 '24 17:05 jeffstoner-scilo

In our particular use-case, we follow the approach:

.env.dev (public variables) .env.dev.local (for overrides not tracked) .env.test (public variables with priority over .env.dev) .env.test.local (for overrides not tracked on git)

We then have an outside system Secrets as a Service called Infisical (pretty much an HashiCorp Vault for cool kids :p), that pushes some secret variables to GitHub Secrets during builds.

The workflow in question is shared across multiple projects in a monorepo. Not all of them have or need a .env.test. Because this action fails, we can't* share the workflow. Our alternative currently, is to check if .env.test exists on the current directory and conditionally calling the action, but this could probably be avoided if there was a flag to not error on file not found. :)

FranciscoKloganB avatar May 15 '24 19:05 FranciscoKloganB

@jeffstoner-scilo you could as well always have an empty .env file in the project template.

@FranciscoKloganB in your case I see it's a bit more complex (or are you working in the same organization?).

Either way, I think it could be helpful to have such feature and it wouldn't be too hard to add it. However, I am busy at the moment but will review a pull request if you'd send one.

falti avatar May 16 '24 07:05 falti

We are not in the same org.

I will look into your source code this weekend! :cheers:

FranciscoKloganB avatar May 16 '24 22:05 FranciscoKloganB