This action generates a dotenv file (for use in a GitHub Actions workflow) by running envsubst
on a specified template file (e.g., _.env
) or multiple template files (e.g., _.env
and _.env.production
), which must
be included in source control.
A space-delimited list of filepaths of the template files that will be used to generate the dotenv file.
This could be a single filepath (e.g., '_.env'
or '.env.template'
) or multiple filepaths
(e.g., '_.env _.env.production'
).
If multiple paths are specified, the templates will be merged (with duplicate variable keys removed, giving priority to the contents of the right-most paths) to produce the final dotenv file. This can be useful for dynamically overriding a base dotenv template depending on the environment for which the dotenv file is being produced.
(Optional) The path of the output dotenv file. Default: '.env'
(Optional) Boolean specifying whether to cache the dotenv file. Default: 'true'
(Optional) The key used to cache the dotenv file (if caching is not disabled).
If key
is not specified, a cache key is computed by concatenating the template paths
and the GITHUB_SHA
environment variable.
(Optional) Boolean specifying whether to generate the dotenv file even if one or more variables
referenced in the template file is missing from the environment. Default: 'false'
The key used to cache the dotenv file (if caching is not disabled), or null (if caching is disabled).
name: Generate dotenv file
on: [push]
jobs:
generate-dotenv-file:
name: Generate dotenv file
runs-on: ubuntu-latest
env:
OMITTED_VAR: asdf
SHA: ${{ github.sha }}
steps:
- uses: actions/checkout@v3
- uses: iacobfred/[email protected]
with:
template-paths: ".config/_.env"
output-path: ".env"
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
VAR_TO_BE_RENAMED: ghjkl
SHA=$SHA
SECRET_KEY=$SECRET_KEY
RENAMED_VAR=$VAR_TO_BE_RENAMED
NONSECRET_IMMUTABLE_VAR=12345
SHA=5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
SECRET_KEY=Kt4Gn4XRgAMy7EHZPp
RENAMED_VAR=ghjkl
NONSECRET_IMMUTABLE_VAR=12345