GitHub Action
export-env-action
Can be useful if you want to use .env file as a storage of constants among multiple workflows.
# constants.env file
VAR1=abc
VAR2=def
- uses: cardinalby/export-env-action@v2
with:
envFile: 'constants.env'
# env.VAR1 == 'abc'
# env.VAR2 == 'def'
# constants1.env file
VAR1=abc
VAR2=def
# constants2.env file
VAR2=ghi
VAR3=jkl
- uses: cardinalby/export-env-action@v2
with:
envFile: 'constants1.env|constants2.env'
# env.VAR1 == 'abc'
# env.VAR2 == 'ghi'
# env.VAR3 == 'jkl'
# constants.env file
VAR1=abc
VAR2=def
VAR3=ghi
- uses: cardinalby/export-env-action@v2
with:
envFile: 'constants.env'
filter: 'VAR1|VAR3'
# env.VAR1 == 'abc'
# env.VAR3 == 'jkl'
# constants.env file
PROTOCOL=https
HOST=example.com
PORT=8080
URI=${PROTOCOL}://${HOST}:${PORT}
- uses: cardinalby/export-env-action@v2
with:
envFile: 'constants.env'
expand: 'true'
# env.PROTOCOL == 'https'
# env.HOST == 'example.com'
# env.PORT == '8080'
# env.URI == 'https://example.com:8080'
# constants.env file
VAR1=abc
VAR2=def
- uses: cardinalby/export-env-action@v2
id: exportStep
with:
envFile: 'constants.env'
export: 'false'
# env.VAR1 == ''
# env.VAR2 == ''
# steps.exportStep.outputs.VAR1 == 'abc'
# steps.exportStep.outputs.VAR2 == 'def'
Path to env file to parse.
Filter regexp to only export specific variables matching the filter.
It filters both exported variables and action outputs (if export: false
), but doesn't impacts variables extending and masking.
If filter is: 'VAR_1|VAR_3'
VAR_1=aaa
VAR_2=bbb
VAR_3=ccc
Will lead to following exported variables: VAR_1 = aaa
, VAR3 = ccc
.
If true
, "expands" variables:
VAR_1=aaa
VAR_2=${VAR_1}_bbb
Will lead to following exported variables: VAR1 = aaa
, VAR2 = aaa_bbb
.
Read more about expand engine rules here.
If true
, "expands" variables considering step (job) env variables (in addition to variables defined in the same env file).
It means, ${GITHUB_RUN_ATTEMPT}
in a variable value will be substituted by the value of $GITHUB_RUN_ATTEMPT
job env variable.
Export variables to a job environment. If false
, all variables will be set as an action
outputs instead.
If true
masks all result values (after expanding) as secrets.
Warning: be cautious if you want to use this option, it is bad idea to store secrets in
.env
file in the repo, use GitHub secrets for that purpose.
If export
is false
then there are individual outputs for each variable from env file (where output name equals variable name).