fix: pass environment variables to mise commands (#341)

## Summary
- Environment variables are now always passed to mise commands
- Previously, env vars were only passed when in debug mode, meaning
`MISE_ENV` and other `MISE_*` variables set in the workflow were not
passed through during `mise install`

Fixes #289

## Usage
```yaml
env:
  MISE_ENV: production

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: jdx/mise-action@v2
        # MISE_ENV=production is now passed to mise install
```

## Test plan
- [ ] Verify setting `MISE_ENV` in workflow env is passed to `mise
install`
- [ ] Verify debug mode still works (adds `MISE_LOG_LEVEL: debug`)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Always pass sanitized workflow environment variables to all `mise`
invocations, adding `MISE_LOG_LEVEL=debug` only in debug mode.
> 
> - **Action runtime**:
> - Always pass environment variables to `mise` commands via a sanitized
`baseEnv` (filters out `undefined`).
> - In debug mode, extends `baseEnv` with `MISE_LOG_LEVEL=debug`;
otherwise uses `baseEnv` unchanged.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
fb448d9e635736cb69b6190690272e10a34bc890. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
jdx 2025-12-16 12:33:26 -06:00 committed by GitHub
parent 61e6c4a9e9
commit a14eb4219a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 5 deletions

5
dist/index.js generated vendored
View file

@ -50291,9 +50291,10 @@ const mise = async (args) => await core.group(`Running mise ${args.join(' ')}`,
const cwd = core.getInput('working_directory') ||
core.getInput('install_dir') ||
process.cwd();
const baseEnv = Object.fromEntries(Object.entries(process.env).filter((entry) => entry[1] !== undefined));
const env = core.isDebug()
? { ...process.env, MISE_LOG_LEVEL: 'debug' }
: undefined;
? { ...baseEnv, MISE_LOG_LEVEL: 'debug' }
: baseEnv;
if (args.length === 1) {
return exec.exec(`mise ${args}`, [], {
cwd,

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -351,9 +351,14 @@ const mise = async (args: string[]): Promise<number> =>
core.getInput('working_directory') ||
core.getInput('install_dir') ||
process.cwd()
const baseEnv = Object.fromEntries(
Object.entries(process.env).filter(
(entry): entry is [string, string] => entry[1] !== undefined
)
)
const env = core.isDebug()
? { ...process.env, MISE_LOG_LEVEL: 'debug' }
: undefined
? { ...baseEnv, MISE_LOG_LEVEL: 'debug' }
: baseEnv
if (args.length === 1) {
return exec.exec(`mise ${args}`, [], {