falti / dotenv-action Goto Github PK
View Code? Open in Web Editor NEWProvide common parameters via .env file
License: MIT License
Provide common parameters via .env file
License: MIT License
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! :)
For example if I have an .env with:
foo=123
I may want to export the env variables with the prefix TF_VAR_
so that Terraform can automatically process the foo
variable... as well as be able to reference the step.my-step.outputs.foo
in my workflow.
Using export-variables: true
makes the name of variable lowercase inside following steps.
i.e. WEB_PORT
-> web_port
, so you can't refer to it as ${WEB_PORT}
how you would expect.
Expected behaviour: exporting environment variables keeps casing of their names.
Related to #42.
I would like to propose the addition of an option (export-variables
) that exports the key value pairs as environment variables in addition to setting them as the output.
This makes it easier to use this action with steps that expect the values in environment variables, meaning that we don't need to write an intermediate step that takes the output and exports them as environment variables.
Starting from October, 11th 2022 using the latest version of this action (falti/[email protected]
) yields deprecation warnings:
The
set-output
command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
It looks like simply upgrading the @actions/core
dependency to 1.10.0
or newer should fix this issue.
Imported your actions, but it seems they are still using the deprecated format for output when using it in the workflow it would prompt the warning:
Warning: The
set-output
command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Think you can review and update?
nice action btw
I'm using a mono repo and I'm looking to define a path to a .env
file in a package like so
- name: Load .env.development variables (Development)
if: startsWith(github.ref, 'master') != true
id: dotenv
with:
path: packages/website/.env.development
But no matter how I try to define the path I always get a ##[error]file does not exist
error
GitHub has deprecated Node 16 in GH Actions. Do you have a timeline for upgrading before their "spring 2024" deadline for the switchover?
https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
We use falti/dotenv-action V1 in our workflows.
Following is the GH action step to read env props;
- name: Read environment variables from .env file
id: dotenv
uses: falti/[email protected]
with:
log-variables: true
However, we can see set-output warnings.
We would appreciate it if you could investigate this. cc @falti
I am trying to use this action to change the value of an existing environment variable but it appears to ignore the value in the env file in this case.
For example:
Environment already has FOO=BAR
Create env file with FOO=BAZ
Add this to the workflow
- name: Setup environment
uses: falti/[email protected]
with:
path: global.env
keys-case: "bypass"
log-variables: true
export-variables: true
And observe the following in the log:
loading .env file from global.env
{
FOO: 'BAR'
}
I'm not sure whether this behaviour is by design? Would it be possible to log a warning in this case or ideally provide a flag to have the dotenv-action override the existing key value with the new one?
Example: Say, there is a .env
file with below key/value pairs:
TEST_ENV=staging
BASE_URL=https://example-${TEST_ENV}.org
From the output, it's clear that it's not able to replace the value of TEST_ENV
i.e., staging
for the env variable BASE_URL
i.e., https://example-staging.org
| loading .env file from ./tests/.env
| loaded 2 values into the environment
[Run Smoke Tests/test] ⚙ ::set-output:: generic=please check for actual outputs
[Run Smoke Tests/test] ⚙ ::set-output:: test_env=staging
[Run Smoke Tests/test] ⚙ ::set-output:: base_url=https://example-${TEST_ENV}.org
Ideally, would expect the output to be:
| loading .env file from ./tests/.env
| loaded 2 values into the environment
[Run Smoke Tests/test] ⚙ ::set-output:: generic=please check for actual outputs
[Run Smoke Tests/test] ⚙ ::set-output:: test_env=staging
[Run Smoke Tests/test] ⚙ ::set-output:: base_url=https://example-staging.org
Not sure, how to achieve this. Please advise.
Note: Used as below:
- name: Dotenv Action
id: dotenv
uses: falti/[email protected]
with:
path: ./tests/.env
Not sure what I'm doing wrong, but neither the upper or lower cases seem to net out with any values?
.env
GATSBY_SITE_URL = "https://test.domain.com"
GATSBY_STACKNAME = "brand-x-feat-submit"
workflow.yml
...
- name: Slurp Up .env
uses: falti/[email protected]
- name: Test
run: |
echo "${{ steps.dotenv.outputs.gatsby_site_url }}"
echo "${{ steps.dotenv.outputs.gatsby_stackname }}"
...
Also tried...which btw, feels more intuitive, not sure why it should lowercase them?
...
- name: Slurp Up .env
uses: falti/[email protected]
- name: Test
run: |
echo "${{ steps.dotenv.outputs.GATSBY_SITE_URL }}"
echo "${{ steps.dotenv.outputs.GATSBY_STACKNAME }}"
...
Hi,
Thanks for this great action that works fine.
As i'm using terraform and tfvars files, there's a duplication in defining environnemnt variables as i need to use a .env file now.
Would it be possible to be able to select my own file and path which contains variables ? with a different name than .env ?
I think this action is stable so why don't we create a tag v1
.
Other GitHub Actions use v1.0.0
and v1
.
The tag v1
is used as an alias so it points to the latest stable version.
Hi @falti
can you please add a new feature to support multine values?
dotenv v15.0.0 supports multiline values.
for example;
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----
...
Kh9NV...
...
-----END DSA PRIVATE KEY-----"
Not at all clear
Step 1: I created a .env file and added some data
Step 2: In existing workflow i used this action try to log it out and it is throwing an error, checkout action is not there ?
Please provide a clear example with a demo repository ?
Note : Don't know why people make actions and don't Provide example ?
Hope you guys provide it with a good example. How to use it
Thanks
Saiteja Gurram
Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: falti/dotenv-action
I noticed that key names are being lower-cased: https://github.com/falti/dotenv-action/blob/master/dotenv_action.js#L16
This is surprising behaviour as variable names are case-sensitive and some applications expect them to be in ALL UPPERCASE.
Perhaps we can introduce an option to not lower-case the keynames, which will be backwards compatible with the current behavior.
ensure-exists
is missing in the action.yml file, which triggers warnings while running (but it does work).
Lines 6 to 30 in 7a3a44a
ensure-exists:
description: "Fail the action when .env file is not found at path."
required: false
default: "true"
Hello @falti @oschlegel @falti where I'm I supposed to place my .env file? I am Getting file does not exist error. my folder structure looks like:
reporoot
.github
workflows
githubaction.yml --i'm reading the .env from here
.env --this is the .env file
Please help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.