Environment variables (or .env files)

I see that Github actions support global environment variables at the job level right now. However, suppose those variables are in a .env file. Would there be some way to dump that into GITHUB_ENV file so that it can be used as an environment variable there?

Assuming your .env file follows the format required by GITHUB_ENV you can just append it all:

steps:
  - name: read environment file
    run: cat .env >>${GITHUB_ENV}

If the .env file uses a different format you’ll have to run it through some kind of converter tool instead of simply copying, e.g. a script that reads the environment file and writes to GITHUB_ENV in the expected format.

1 Like

Sorry, I somehow didn’t put the key word here, at the job level I mean. You can’t run anything at that level, right?

You mean before any steps get run? There’s no option for that. Maybe because the .env file wouldn’t be available before checkout anyway?

On the other hand settings in GITHUB_ENV remain for the rest of the job, so the effect is very similar.