A GitHub Action to seed environment variables into a env file by merging an example file with user-provided values in JSON format. Useful for CI/CD pipelines or setting up local environments consistently.
- Flexible – Supports any file name or path, not just regular
.envand.env.example - Clean – Preserves structure, handles empty lines, and quotes values when needed
- Simple – No magic, no complex config — just JSON input and a reliable result
name: CI Workflow
on: push
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Seed environment variables
uses: scrlkx/dotenv-seeder@v2
with:
example: ".env.example"
target: ".env"
variables: |
{
"API_KEY": "{{ secrets.API_KEY }}",
"DEBUG": "true",
"BASE_URL": "{{ env.BASE_URL }}"
}| Name | Description | Required | Default |
|---|---|---|---|
mode |
Seeding mode — see Modes below | No | copy-example |
example |
The example file to copy from if the target file does not exist | No | .env.example |
target |
The environment file to update or create | No | .env |
variables |
A JSON object containing environment variables to inject | Yes | — |
The mode input controls whether an example file is required to seed the target file.
Copies example to target before applying variables. The example file must exist, or the action fails.
with:
mode: "copy-example" # optional, this is the default
example: ".env.example"
target: ".env"
variables: |
{ "API_KEY": "{{ secrets.API_KEY }}" }Writes or updates target directly, without requiring or copying an example file. Use this when there is no .env.example to seed from.
with:
mode: "only-create"
target: ".env"
variables: |
{ "API_KEY": "{{ secrets.API_KEY }}" }GPL-3.0 License - see the LICENSE file for details