Can I access the value in an env file from a python script using os.getenv? #25415
-
Hi, I have a question about the new environment files we should use instead of the set env. I am using an env variable to store the current tag number to pass it to a python script.
And in my python script I used:
Does this still work with the new files? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Yes, under the same conditions as before: The Python script must be called in a later step that’s part of the same job. |
Beta Was this translation helpful? Give feedback.
-
Sure, using “os.getenv(‘ENV_NAME’)” or “os.environ[‘ENV_NAME’]” in Python scripts to access environment variables still can work. In addition, the old workflow command (echo “::set-env name={name}::{value}”) to set an environment variable has been deprecated. |
Beta Was this translation helpful? Give feedback.
@siedlerchr,
Sure, using “os.getenv(‘ENV_NAME’)” or “os.environ[‘ENV_NAME’]” in Python scripts to access environment variables still can work.
In addition, the old workflow command (echo “::set-env name={name}::{value}”) to set an environment variable has been deprecated.
Currently, the old command still can work in the workflows, however we recommend that you use the new command (echo “{name}={value}” >> $GITHUB_ENV).
More details, see “Setting an environment variable”.