add all MISE_ env vars to cache key (#197)

Co-authored-by: jdx <216188+jdx@users.noreply.github.com>
This commit is contained in:
Gregor Zeitlinger 2025-06-17 19:12:06 +02:00 committed by GitHub
parent 883a83c54f
commit a5b33d7b88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 7 deletions

9
dist/index.js generated vendored
View file

@ -66588,7 +66588,10 @@ async function restoreMiseCache() {
core.startGroup('Restoring mise cache');
const version = core.getInput('version');
const installArgs = core.getInput('install_args');
const { MISE_ENV } = process.env;
// all env vars that start with MISE_ are used in the cache key
// this allows users to set MISE_ENV or other variables that affect the cache
// without having to modify the cache key prefix
const env_key = JSON.stringify(Object.fromEntries(Object.entries(process.env).filter(([key]) => key.startsWith('MISE_'))));
const cachePath = miseDir();
const fileHash = await glob.hashFiles([
`**/.config/mise/config.toml`,
@ -66622,8 +66625,8 @@ async function restoreMiseCache() {
if (version) {
primaryKey = `${primaryKey}-${version}`;
}
if (MISE_ENV) {
primaryKey = `${primaryKey}-${MISE_ENV}`;
if (env_key) {
primaryKey = `${primaryKey}-${env_key}`;
}
if (installArgs) {
const tools = installArgs

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -65,7 +65,14 @@ async function restoreMiseCache(): Promise<string | undefined> {
core.startGroup('Restoring mise cache')
const version = core.getInput('version')
const installArgs = core.getInput('install_args')
const { MISE_ENV } = process.env
// all env vars that start with MISE_ are used in the cache key
// this allows users to set MISE_ENV or other variables that affect the cache
// without having to modify the cache key prefix
const env_key = JSON.stringify(
Object.fromEntries(
Object.entries(process.env).filter(([key]) => key.startsWith('MISE_'))
)
)
const cachePath = miseDir()
const fileHash = await glob.hashFiles(
[
@ -101,8 +108,8 @@ async function restoreMiseCache(): Promise<string | undefined> {
if (version) {
primaryKey = `${primaryKey}-${version}`
}
if (MISE_ENV) {
primaryKey = `${primaryKey}-${MISE_ENV}`
if (env_key) {
primaryKey = `${primaryKey}-${env_key}`
}
if (installArgs) {
const tools = installArgs