Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacobjove/generate-dotenv
Generates a dotenv file as part of a GitHub Actions workflow.
https://github.com/jacobjove/generate-dotenv
dotenv github-actions
Last synced: about 19 hours ago
JSON representation
Generates a dotenv file as part of a GitHub Actions workflow.
- Host: GitHub
- URL: https://github.com/jacobjove/generate-dotenv
- Owner: jacobjove
- License: mit
- Created: 2022-09-05T00:32:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-24T13:51:39.000Z (8 months ago)
- Last Synced: 2024-04-24T16:56:03.215Z (8 months ago)
- Topics: dotenv, github-actions
- Language: TypeScript
- Homepage:
- Size: 2.99 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Generate dotenv file
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.## Inputs
### `template-paths`
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.### `output-path`
(Optional) The path of the output dotenv file. Default: `'.env'`
### `cache`
(Optional) Boolean specifying whether to cache the dotenv file. Default: `'true'`
### `key`
(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.### `allow-missing-vars`
(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'`## Outputs
### `key`
The key used to cache the dotenv file (if caching is not disabled), or null (if caching is disabled).
## Example usage
### `.github/workflows/[workflow].yml`
```yaml
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
```### `.config/_.env`
```sh
SHA=$SHA
SECRET_KEY=$SECRET_KEY
RENAMED_VAR=$VAR_TO_BE_RENAMED
NONSECRET_IMMUTABLE_VAR=12345
```### Output: `.env`
```sh
SHA=5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
SECRET_KEY=Kt4Gn4XRgAMy7EHZPp
RENAMED_VAR=ghjkl
NONSECRET_IMMUTABLE_VAR=12345
```