GitHub Action that validates environment variables against schemas and .env.example files in CI. Produces inline PR annotations for each issue.
- name: Check env varsuses: fixedbydev/envguard-action@v1with:
env-file: .env.exampleexample-file: .env.example.dist- name: Audit env usageuses: fixedbydev/envguard-action@v1with:
schema: ./env.schema.tssrc-dir: ./srcfail-on: undeclared,missing- name: Validate environmentuses: fixedbydev/envguard-action@v1with:
env-file: .env.productionexample-file: .env.examplefail-on: missing| Input | Description | Default |
|---|---|---|
env-file | Path to .env file to validate | .env.example |
schema | Path to env.schema.ts for audit | (optional) |
example-file | Path to .env.example for diff | (optional) |
format | Output format: github, json, pretty | github |
fail-on | Comma-separated fail conditions: undeclared, missing, unused, unsafe | undeclared,missing |
working-directory | Working directory (monorepo support) | . |
src-dir | Source directory for audit scan | ./src |
| Output | Description |
|---|---|
valid | true if all checks passed, false otherwise |
undeclared | JSON array of undeclared env var keys |
missing | JSON array of missing env var keys |
unused | JSON array of unused schema keys |
name: Env Checkon: pull_requestjobs:
env-check:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v4
- uses: fixedbydev/envguard-action@v1with:
env-file: .env.exampleexample-file: .env.example.distname: Env Auditon: [push, pull_request]jobs:
audit:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v4
- uses: fixedbydev/envguard-action@v1with:
schema: ./env.schema.tssrc-dir: ./srcfail-on: undeclared- name: Validate envid: envguarduses: fixedbydev/envguard-action@v1continue-on-error: truewith:
env-file: .env.exampleexample-file: .env.example.dist
- name: Handle resultsrun: | echo "Valid: ${{ steps.envguard.outputs.valid }}" echo "Missing: ${{ steps.envguard.outputs.missing }}"- uses: fixedbydev/envguard-action@v1with:
working-directory: ./packages/apienv-file: .env.exampleschema: ./env.schema.ts- Runs in a Docker container (Node 20 Alpine)
- Installs
@stacklance/envguard-cliand@stacklance/envguard-audit - Performs diff (
.envvs.env.example) and/or schema audit - Emits
::error::and::warning::annotations for GitHub PR integration - Sets action outputs via
$GITHUB_OUTPUT - Exits with code 1 if any
fail-oncondition is met
# Install act: https://github.com/nektos/act
act -j test-diff-passMIT