You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using act to debug Actions locally and encountered a behavior that I'd like to discuss. My use case involves running a test workflow with a Postgres service, where the DB credentials are set as environment variables. In my local setup, these credentials are defined in a .env file for docker-compose, they are specific for my Docker environment, and some dummy credentials are set in the .github/workflows/ci.yml file. Here's a snippet of the ci.yml:
While using act -j tests, I noticed that the .env file, which is gitignored, was unexpectedly influencing the environment variables in the container. This behavior is due to act's default handling of .env files:
$ act --help
<...>
--env-file string environment file to read and use as env in the containers (default ".env")
I'm curious about the rationale behind this default behavior. In my view, when using act to simulate GitHub Actions locally, the expectation is that only the environment variables defined in the workflow YAML should be considered, unless explicitly overridden. The automatic inclusion of the .env file, especially when it's commonly used for other development purposes, seems counterintuitive and potentially problematic.
Consider this simple example for clarity:
.github/workflows/test.yml:
name: Testenv:
SAMPLE_VAR: 'foo'jobs:
test:
runs-on: ubuntu-lateststeps:
- name: Show the varrun: echo $SAMPLE_VAR
.env contents:
SAMPLE_VAR=bar
Running act -j test outputs bar instead of the expected foo.
Given these observations, wouldn't it be more intuitive for act to not use --env-file by default or at least provide a clearer warning about this behavior?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey everyone!
I've been using
act
to debug Actions locally and encountered a behavior that I'd like to discuss. My use case involves running a test workflow with a Postgres service, where the DB credentials are set as environment variables. In my local setup, these credentials are defined in a.env
file for docker-compose, they are specific for my Docker environment, and some dummy credentials are set in the.github/workflows/ci.yml
file. Here's a snippet of theci.yml
:While using
act -j tests
, I noticed that the.env
file, which is gitignored, was unexpectedly influencing the environment variables in the container. This behavior is due toact
's default handling of.env
files:I'm curious about the rationale behind this default behavior. In my view, when using
act
to simulate GitHub Actions locally, the expectation is that only the environment variables defined in the workflow YAML should be considered, unless explicitly overridden. The automatic inclusion of the.env
file, especially when it's commonly used for other development purposes, seems counterintuitive and potentially problematic.Consider this simple example for clarity:
.github/workflows/test.yml
:.env
contents:Running
act -j test
outputsbar
instead of the expectedfoo
.Given these observations, wouldn't it be more intuitive for
act
to not use--env-file
by default or at least provide a clearer warning about this behavior?Beta Was this translation helpful? Give feedback.
All reactions