Skip to content

Commit a5b33d7

Browse files
zeitlingerjdx
andauthored
add all MISE_ env vars to cache key (#197)
Co-authored-by: jdx <[email protected]>
1 parent 883a83c commit a5b33d7

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

dist/index.js

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@ async function restoreMiseCache(): Promise<string | undefined> {
6565
core.startGroup('Restoring mise cache')
6666
const version = core.getInput('version')
6767
const installArgs = core.getInput('install_args')
68-
const { MISE_ENV } = process.env
68+
// all env vars that start with MISE_ are used in the cache key
69+
// this allows users to set MISE_ENV or other variables that affect the cache
70+
// without having to modify the cache key prefix
71+
const env_key = JSON.stringify(
72+
Object.fromEntries(
73+
Object.entries(process.env).filter(([key]) => key.startsWith('MISE_'))
74+
)
75+
)
6976
const cachePath = miseDir()
7077
const fileHash = await glob.hashFiles(
7178
[
@@ -101,8 +108,8 @@ async function restoreMiseCache(): Promise<string | undefined> {
101108
if (version) {
102109
primaryKey = `${primaryKey}-${version}`
103110
}
104-
if (MISE_ENV) {
105-
primaryKey = `${primaryKey}-${MISE_ENV}`
111+
if (env_key) {
112+
primaryKey = `${primaryKey}-${env_key}`
106113
}
107114
if (installArgs) {
108115
const tools = installArgs

0 commit comments

Comments
 (0)