feat: export env vars from mise.toml (#241)

Solve https://github.com/jdx/mise-action/issues/36

BREAKING CHANGE: we're defaulting this behavior to `true`

---------

Co-authored-by: jdx <216188+jdx@users.noreply.github.com>
This commit is contained in:
Mael 2025-08-18 18:33:13 +02:00 committed by GitHub
parent e7e48454f4
commit f0b1d70eae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 22 additions and 2 deletions

View file

@ -1,4 +1,4 @@
name: 'build-test'
name: "build-test"
on: # rebuild any PRs and main branch changes
pull_request:
branches:
@ -50,6 +50,9 @@ jobs:
mise_toml: |
[tools]
jq = "1.7.1"
[env]
MY_ENV_VAR = "abc"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: mise --version

View file

@ -70,6 +70,10 @@ inputs:
required: false
default: "true"
description: If true (default), fetch the mise binary from GitHub. If false and using the latest version, fetch from mise.jdx.dev instead.
env:
description: "Automatically load mise env vars into GITHUB_ENV. Note that PATH modifications are not part of this."
required: false
default: "true"
outputs:
cache-hit:
description: A boolean value to indicate if a cache was hit.

5
dist/index.js generated vendored
View file

@ -66558,6 +66558,11 @@ async function run() {
}
}
await miseLs();
const loadEnv = core.getBooleanInput('env');
if (loadEnv) {
const output = await exec.getExecOutput('mise', ['env', '--dotenv']);
fs.appendFileSync(process.env.GITHUB_ENV, output.stdout);
}
}
catch (err) {
if (err instanceof Error)

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -16,3 +16,6 @@ which jq
if [[ "$(uname)" != "MINGW"* ]]; then
assert_equal "$EXPECTED_OUTPUT" "$(jq --version)"
fi
# checking that environment variables set in mise.toml are properly set
assert_equal "${MY_ENV_VAR}" "abc"

View file

@ -35,6 +35,11 @@ async function run(): Promise<void> {
}
}
await miseLs()
const loadEnv = core.getBooleanInput('env')
if (loadEnv) {
const output = await exec.getExecOutput('mise', ['env', '--dotenv'])
fs.appendFileSync(process.env.GITHUB_ENV!, output.stdout)
}
} catch (err) {
if (err instanceof Error) core.setFailed(err.message)
else throw err