Skip to content

feat: add cache-matched-key output#68

Merged
jackieli-tes merged 3 commits intomainfrom
add-cache-matched-key
Mar 11, 2026
Merged

feat: add cache-matched-key output#68
jackieli-tes merged 3 commits intomainfrom
add-cache-matched-key

Conversation

@jackieli-tes
Copy link
Contributor

Summary

  • Add a new cache-matched-key output that reports the key of the cache entry that was found during restore
  • When an exact match is found, cache-hit is true and cache-matched-key equals the input key
  • When a restore-keys prefix match is found, cache-hit is false but cache-matched-key is set to the matching restore key
  • On error paths, cache-matched-key is set to an empty string for consistency with cache-hit

Fixes #62

Changes

  • src/utils.ts: Added setCacheMatchedKeyOutput helper function
  • src/restore.ts: Call setCacheMatchedKeyOutput in all code paths (success, error, fallback)
  • action.yml and restore/action.yml: Declare the new cache-matched-key output
  • README.md: Added usage example showing restore-keys with cache-matched-key
  • Rebuilt dist/ bundles

Test plan

  • Verify exact key match sets cache-matched-key to the primary key
  • Verify restore-key prefix match sets cache-matched-key to the matching restore key
  • Verify failed restore sets cache-matched-key to empty string
  • Verify fallback cache path sets cache-matched-key to the fallback matching key

Only assert cache-matched-key value when cache-hit is true,
since transient S3 failures result in empty output by design.
@jackieli-tes jackieli-tes merged commit 2d459fd into main Mar 11, 2026
36 checks passed
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.

💡 - Output documentation and alignment with actions/cache outputs

1 participant