cache icon indicating copy to clipboard operation
cache copied to clipboard

Add cache-primary-key and cache-matched-key outputs to actions/cache

Open stuartleeks opened this issue 7 months ago • 1 comments

Add cache-primary-key and cache-matched-key outputs from actions/cache/restore action to actions/cache action

Description

The actions/cache/restore action provides cache-hit, cache-primary-key and cache-matched-key outputs, but the actions/cache only exposes cache-hit.

Motivation and Context

Currently, determining the cache key that was matched requires using restore/save separately. This PR enables using the primary/matched cache keys in subsequent steps using actions/cache.

How Has This Been Tested?

Updated test code in the repo. Also the PR branch from another repo

Screenshots (if appropriate):

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [X] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Documentation (add or update README or docs)

Checklist:

  • [X] My code follows the code style of this project.
  • [X] My change requires a change to the documentation.
  • [X] I have updated the documentation accordingly.
  • [X] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
  • [X] All new and existing tests passed.

stuartleeks avatar May 08 '25 17:05 stuartleeks

~Yes please, at the moment the README has examples that use the cache-primary-key output and they don't work.~

EDIT: I missed that the examples were using actions/cache/restore which does output the cache-primary-key.

leonnicolas avatar Aug 20 '25 11:08 leonnicolas