HatsuneMiku3939/direnv-action
HatsuneMiku3939/direnv-action has 29 GitHub stars and 11 forks. GitHot measured 0 stars in 24 hours, 0 in 7 days, and 0 in 15 days. Last checked 2026-11-21 09:15 UTC. Last push 2026-11-17.
Measured star growth
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
About
Provide environment variables via direnv.
Developer ToolsREADME.md
Originaldirenv action
Provides environment variables via direnv
This action provides environment variables via direnv,
evaluates the target .envrc, and exports the resulting environment variables
to subsequent workflow steps.
Documentation site: https://hatsunemiku3939.github.io/direnv-action/
Who uses this action
How it works
The action performs the following steps:
- Installs the requested
direnvversion from the GitHub release assets or a cache. Cold installs verify the downloaded binary's SHA-256 digest before execution or caching. - Runs
direnv allowfor the configuredpath. - Runs
direnv export jsonin the configuredpath. - Logs the exported environment variable names without printing their values.
- Optionally verifies that required environment variable names were exported.
- Exports the resulting variables to the GitHub Actions environment.
- Appends
PATHentries throughcore.addPath()whenPATHis present in the exported values. - Masks configured secret values with the GitHub Actions masking API.
Inputs
direnvVersion: Thedirenvversion to use. Default:2.37.1.direnvChecksum: Optional SHA-256 checksum for the downloadeddirenvbinary. Default:''.masks: A comma-separated list of environment variable names to mask. Default:''.required: A newline-delimited list of environment variable names that must be exported. Default:''.path: The directory wheredirenv allowanddirenv export jsonare executed. Default:..
Outputs
No outputs
Example usage
Examples below pin the current release, v1.4.9. If you prefer compatible updates within the current major line, use the moving major tag @v1.
uses: HatsuneMiku3939/[email protected]
with:
direnvVersion: 2.37.1
masks: SECRET1, SECRET2
This loads the .envrc file from the repository root.
By default, cold installs verify the downloaded direnv binary against the GitHub Release API asset digest. To pin an
expected digest yourself, set direnvChecksum to either a plain SHA-256 hex digest or a sha256:<digest> value:
uses: HatsuneMiku3939/[email protected]
with:
direnvVersion: 2.37.1
direnvChecksum: sha256:1f1b93dd6f38523fde26dfac96151ef9d31a374e3005cd3345fb93555ae0c9b5
To evaluate the .envrc in a subdirectory, set path explicitly:
uses: HatsuneMiku3939/[email protected]
with:
path: child
masks: SECRET1, SECRET2
To fail early when expected variables are not exported, set required:
uses: HatsuneMiku3939/[email protected]
with:
required: |
AWS_REGION
DATABASE_URL
NODE_AUTH_TOKEN
For the most predictable builds, pin an exact version tag such as @v1.4.9. Use @v1 only when you want to receive the latest compatible v1.x.y release automatically.
Behavior notes
masksaccepts environment variable names, not raw secret values.requiredaccepts environment variable names, not raw values, and fails when any listed name is absent from the exported environment.- When
.envrcexportsPATH, the action appends it to the jobPATHinstead of overwriting the entire value. - Variables exported by
direnv export jsonare available to later workflow steps in the same job. - The action logs exported variable names for debugging, but it does not print environment variable values.
- The action does not define custom outputs; consumers should read exported environment variables directly.
- Cold installs verify the downloaded
direnvbinary before marking it executable or saving it to any cache. - When
direnvChecksumis provided, the action cache key includes that checksum so different pins do not share cache entries.
Security considerations
This action evaluates .envrc, which means repository code can influence the shell commands executed by direnv. Treat
.envrc as executable code, especially in workflows that can access repository secrets, cloud credentials, deployment
tokens, or production infrastructure.
- Only use this action with trusted repositories and trusted
.envrccontents. - Avoid evaluating untrusted fork contents from
pull_request_targetworkflows. If you usepull_request_target, do not check out and run a fork-provided.envrcin a job that has access to secrets. - Prefer running secret-bearing jobs only on trusted refs, protected branches, or reviewed tags. For fork PR validation,
use
pull_requestwith minimal permissions and without repository secrets unless the.envrccontents are trusted. - Use the
requiredinput to fail early when expected exported variables are missing. This helps prevent downstream steps from running with incomplete configuration, but it is not a sandbox or a secret-protection boundary. - Keep workflow
permissions:as narrow as possible and avoid passing long-lived credentials into jobs that evaluate changing.envrcfiles. - Treat masking as a log redaction aid, not a complete secret protection boundary.
- Keep sensitive logic inside trusted workflow contexts whenever possible.
- Download verification uses the GitHub Release API asset digest by default. This protects against corrupted or swapped
download bytes relative to GitHub's release metadata. For a stronger independent pin, provide
direnvChecksum.
Development
Run the local quality checks before packaging or releasing changes:
npm run lint
npm test
For dependency updates and release preparation, use the full gate and commit the regenerated dist/ artifacts so the action runs the reviewed dependency versions:
npm run all
The Vitest unit tests cover binary URL selection, downloaded binary checksum verification, tool installation cache branches, environment export behavior, required variable validation, secret masking, and the main action flow with mocked GitHub Actions APIs.
Temporary minimatch compatibility patch
The dependency overrides replace minimatch 10 with 11.0.3 to address
GHSA-g3hv-75wg-m249.
Minimatch 11 removes matchOne(), which @actions/glob 0.7.0 uses for partial
path matching. The tracked patch in patches/ switches that call to the public
match(path, true) API, preserving path normalization and the existing root
handling. Glob disables brace expansion and minimatch negation, so this call
evaluates the same single pattern without applying exclusion twice.
npm ci runs the existing prepare lifecycle, which now applies the patch with
patch-package --error-on-fail before bundling. Keep development dependencies
installed when rebuilding; do not bypass lifecycle scripts for release builds.
The glob version is pinned to the patched version, and a patch mismatch fails
the build. Reapplying the patch is safe. The generated bundle contains the
patched consumer; installing dependencies is not required to run the action.
The build also removes trailing whitespace preserved by ncc from dependency
sources, so regenerated artifacts pass the repository's whitespace checks.
dependency-compat.test.js exercises real cache glob traversal, including
nested and excluded paths, dot-directories, missing paths, and workspaces with
spaces or Unicode. These tests also run on Linux and macOS CI. Remove the glob
pin, patch, and patch-package when a released @actions/glob supports a patched
minimatch version directly; remove the minimatch override when its consumers
no longer resolve vulnerable versions. Rerun the compatibility tests and
regenerate dist/ before removing either workaround.
Supported platforms and architectures
Since v1.0.7, the following platform and architecture combinations are supported.
| Platform | Architecture |
|---|---|
| Linux | x86_64 |
| Linux | arm64 |
| Darwin | x86_64 |
| Darwin | arm64 |
Versions earlier than v1.0.7 support only linux-x86_64.
Contributors
|
Kim SeungSu |
hopisaurus |
Mike Dial |
gidoichi |
Alex Klinkert |
Explore related projects
Loading…