Skip to content

Add example for restore-only cache in documentation - #1419

Merged
v-HarithaVattikuti merged 6 commits into
actions:mainfrom
v-aparnajyothi-y:doc-update-restore-cache-only
Oct 21, 2025
Merged

v-HarithaVattikuti merged 6 commits into
actions:mainfrom
v-aparnajyothi-y:doc-update-restore-cache-only

Conversation

@v-aparnajyothi-y

Copy link
Copy Markdown
Contributor

Description:
This PR adds documentation and an example workflow demonstrating how to achieve restore-only caching with setup-node using the actions/cache.
The update is based on community feedback from #663 (“Add option to restore cache only”), which proposed adding a restore-only flag to the action.
Instead of introducing new functionality, this documentation clarifies how users can already achieve this behavior using actions/cache.
Related issue:
#663

Check list:

  • [ X] Mark if documentation changes are required.

Copilot AI review requested due to automatic review settings October 21, 2025 10:44
@v-aparnajyothi-y
v-aparnajyothi-y requested a review from a team as a code owner October 21, 2025 10:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds documentation demonstrating how to achieve restore-only caching behavior with setup-node by using the actions/cache action directly. This addresses community feedback requesting a restore-only flag without introducing new functionality, instead showing users how to accomplish this with existing tools.

Key Changes:

  • Added a "Restore-Only Cache" section with a complete workflow example
  • Included explanatory note about the benefits of restore-only caching

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread docs/advanced-usage.md Resolved
Comment thread docs/advanced-usage.md Resolved
Aparna Jyothi added 2 commits October 21, 2025 16:18
@Kas-tle

ghost commented Nov 12, 2025

Copy link
Copy Markdown

Not sure why this was merged as this example will pretty much always fail. The key ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} does not match how this action formats its cache keys. Currently, they are formatted as:

node-cache-${{ runner.os }}-RUNNER_ARCH-PACKAGE_MANAGER-${{ hashFiles('**/yarn.lock') }}

Note that runner architecture and package manager must be specified manually as the latter is not provided as action context, and the former, though provided as ${{ runner.arch }} returns uppercase letters instead of lowercase (as this action formats architecture).

Furthermore, the provided path will also fail as caches (at least on Linux runners) are usually stored under /home/runner/..., not /home. It is also worth pointing out that other package managers (e.g. yarn) would require an alternate path (e.g. /home/runner/.yarn/berry/cache).

Finally, the base action from actions/cache is not restore only, so the provided example would actually result in the cache being duplicated... actions/cache/restore should be used instead. See https://github.com/actions/cache/tree/main/restore.

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.

8 participants