Skip to content

Conversation

@pepicrft
Copy link
Contributor

@pepicrft pepicrft commented Aug 22, 2025

I added support for customizing the key, but forgot the most important piece that we need, being able to reference an environment variable value. Our CI runner provider is now exposing an environment variable that indicates if the OS configuration changes, and we plan to use that one to invalidate the cache, otherwise we get errors because the cached dependencies are linking against an invalid / non-existent glibc version.

Important

I wrote the code with claude code and reviewed it afterwards

Summary (Claude-generated)

  • Add support for {{env.VAR_NAME}} syntax in cache key templates to allow reading environment variable values
  • Enables more flexible cache key customization based on CI/CD environment variables like branch names, deployment environments, or custom build identifiers
  • Maintains backward compatibility with existing cache key templates

Examples

# Include branch name from environment
cache_key: 'mise-{{env.GITHUB_REF_NAME}}-{{platform}}-{{file_hash}}'

# Use custom deployment environment
cache_key: 'mise-{{env.DEPLOY_ENV}}-{{platform}}-{{file_hash}}'

# Conditional logic with environment variables
cache_key: '{{default}}{{#if env.CUSTOM_SUFFIX}}-{{env.CUSTOM_SUFFIX}}{{/if}}'

Changes

  • Modified processCacheKeyTemplate() in src/index.ts to include process.env in template data
  • Updated action.yml documentation to include the new {{env.VAR_NAME}} syntax
  • All existing functionality remains unchanged

Test plan

  • Build and package successfully with npm run all
  • Linting and formatting pass
  • Manual testing with environment variables in cache key templates
  • Verify backward compatibility with existing cache key configurations

Add support for {{env.VAR_NAME}} syntax in cache key templates to allow
reading environment variable values. This enables more flexible cache
key customization based on CI/CD environment variables like branch names,
deployment environments, or custom build identifiers.

Examples:
- mise-{{env.GITHUB_REF_NAME}}-{{platform}}-{{file_hash}}
- {{default}}{{#if env.CUSTOM_SUFFIX}}-{{env.CUSTOM_SUFFIX}}{{/if}}
@pepicrft pepicrft requested a review from jdx as a code owner August 22, 2025 09:03
@jdx jdx merged commit 0f242c8 into jdx:main Aug 22, 2025
15 checks passed
@jdx jdx mentioned this pull request Aug 22, 2025
jdx added a commit that referenced this pull request Aug 22, 2025
---
## [3.2.0](https://github.com/jdx/mise-action/compare/v3.1.0..v3.2.0) -
2025-08-22

### 🚀 Features

- add environment variable support to cache key templates (#250) by
[@pepicrft](https://github.com/pepicrft) in
[#250](#250)

### 🐛 Bug Fixes

- redact secret values from env (#252) by [@jdx](https://github.com/jdx)
in [#252](#252)

<!-- generated by git-cliff -->

Co-authored-by: mise-en-dev <123107610+mise-en-dev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants