mise-action

repository·main·Indexed 43 days ago

https://github.com/jdx/mise-action

A GitHub Action for automating the installation and configuration of mise (a tool version manager) in workflows. Supports version 4.3.0, featuring automatic tool installation via .tool-versions or .mise.toml, GitHub Actions caching with customizable Handlebars templates, environment variable exports, and support for locked installs and bootstrap mode.

Tokens
2.6K
Snippets
7
Records
18
Agent score
7%

What's inside mise-action

  1. Configure Environment and PATH export

    main
    The action exports mise environment variables and PATH entries to subsequent workflow steps. PATH entries are added via GITHUB_PATH. To export regular environment variables without persisting mise's PATH changes to the runner, set export_path: false.
  2. Use template variables in cache keys

    main

    When using cache_key, you can use Handlebars-style template variables to ensure cache invalidation is tied to specific configuration changes. You can also extend the default key using {{default}}.

    Available Variables:

    • {{version}}: The mise version.
    • {{cache_key_prefix}}: The prefix used for the key.
    • {{platform}}: The target platform (e.g., linux-x64-ubuntu24).
    • {{file_hash}}: Hash of all mise configuration files.
    • {{mise_env}}: The MISE_ENV environment variable value.
    • {{install_args_hash}}: SHA256 hash of sorted tools from install_args.
    • {{bootstrap_hash}}: SHA256 hash of bootstrap mode, skip list, and args.
    • {{default}}: The processed default cache key.
    - uses: jdx/mise-action@v4
      with:
        cache_key: "mise-v1-{{platform}}-{{install_args_hash}}-{{file_hash}}"
        install_args: "node@24 python@3.14"
  3. Automatic Lock File detection

    main

    If a mise.lock file is present in the working directory or a parent directory, the action automatically runs mise install --locked.

    Note: If you provide mise_toml or tool_versions inputs directly in the workflow, the action does not automatically force locked mode.

  4. Select mise releases by minimum age

    main

    To avoid installing a newly published mise release immediately, omit the version input and set minimum_release_age. This selects the newest stable, non-draft release published before the specified cutoff. Supported formats include relative durations (24h, 7d, 6mo, 1y) and absolute ISO dates/timestamps.

    - uses: jdx/mise-action@v4
      with:
        minimum_release_age: 7d
  5. Customize Cache Configuration and Keys

    main

    You can customize the GitHub Actions cache used by mise-action using cache_key and cache_key_prefix.

    - uses: jdx/mise-action@v4
      with:
        cache_key: "my-custom-cache-key"
        cache_key_prefix: "mise-cache-v1"
  6. Use mise bootstrap mode

    main

    To run mise bootstrap instead of mise install, set bootstrap: true. If a mise.lock file is present, it will run mise --locked bootstrap. Note that install_args cannot be used with bootstrap: true; use bootstrap_skip and bootstrap_args instead.

    - uses: jdx/mise-action@v4
      with:
        bootstrap: true
  7. Use jdx/mise-action@v4 in a GitHub Workflow

    main

    The jdx/mise-action@v4 action installs mise and its tools in your GitHub Actions environment. It can automatically read configuration from .tool-versions or .mise.toml files in your repository root, or you can provide tool definitions directly via workflow inputs. By default, it runs mise install and exports environment variables and PATH entries to subsequent steps.

    steps:
      - uses: actions/checkout@v6
      - uses: jdx/mise-action@v4
        with:
          version: 2026.3.10
          install: true
          install_args: "bun"
          cache: true
          env: true
          export_path: true
      - run: node ./my_app.js
  8. Use mise-action caching

    main

    The action supports caching the mise directory to speed up subsequent runs.

    • Automatic Key Generation: By default, the cache key is generated using a template that includes the platform, version, environment variables, and hashes of configuration files (like .mise.toml or .tool-versions).
    • Custom Keys: You can provide a custom template via the cache_key input.
    • Default Template: {{cache_key_prefix}}-{{platform}}{{#if version}}-{{version}}{{/if}}{{#if mise_env}}-{{mise_env}}{{/if}}{{#if install_args_hash}}-{{install_args_hash}}{{/if}}{{#if bootstrap_hash}}-{{bootstrap_hash}}{{/if}}-{{#if file_hash}}{{file_hash}}{{else}}no-config{{/if}}
  9. Identify the target platform and runner image

    main

    To prevent cache poisoning across different environments, the action generates a platform identifier based on:

    1. Target Platform: Combines the OS and architecture (e.g., macos-armv7, windows-x64, linux-x64, or linux-x64-musl if musl is detected via ldd).
    2. Runner Image ID: Uses the ImageOS environment variable (e.g., ubuntu24) to distinguish between GitHub-hosted runners. If ImageOS is unset, it defaults to self-hosted to accommodate other providers like BuildJet or namespace.so.
  10. Export mise environment variables

    main

    When env: true is set, the action exports environment variables computed by mise.

    • Security: For mise versions $\ge$ 2025.8.17, the action uses mise env --redacted --json to identify sensitive values and automatically masks them using GitHub Actions' core.setSecret.
    • PATH Management: To avoid snapshotting the entire runner environment, the action only adds mise-specific entries to GITHUB_PATH rather than overwriting the PATH variable entirely. This ensures compatibility with other actions.
    • Fallback: If the redacted JSON command fails (on older versions), the action falls back to the --dotenv format.
  11. Determine the mise directory

    main

    The mise_dir is the location where mise stores its data and installed tools. The action resolves this directory using the following priority:

    1. The MISE_DIR state variable (if previously set in the action run).
    2. The mise_dir input.
    3. The MISE_DATA_DIR environment variable.
    4. The XDG_DATA_HOME/mise path (if XDG_DATA_HOME is set).
    5. The LOCALAPPDATA/mise path (on Windows, if LOCALAPPDATA is set).
    6. The default fallback: ~/.local/share/mise.
  12. Use locked installs with mise

    main

    The action can automatically use mise install --locked if certain conditions are met. This ensures that the installation strictly follows the lockfile.

    Locked installation is used ONLY if:

    1. Neither tool_versions nor mise_toml inputs are explicitly provided.
    2. The installed mise binary supports the --locked flag.
    3. A valid mise lockfile is found by searching upwards from the working directory (including checks in .config/mise, .mise, or mise/ directories).