Closed
Conversation
When `read-only` is `true`, the cache is only restored and not saved. This allows for sharing the cache with multiple steps even if these steps may change them, and speeds them up regardless.
Author
|
Does this PR have a future or is it best closed? |
Author
|
Seeing as my PRs to the GitHub repos have been ignored for almost a year, I closed all of them. To clean up my workflows I have decided to work on a fork instead with an (in my eyes) cleaner solution. See the repository for documentation: https://github.com/MartijnHols/actions-cache Here is what sharing cache across jobs would look like: name: Build app
on: push
jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Restore "node_modules" from cache
id: cache
uses: martijnhols/actions-cache/restore@main
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock', 'patches') }}
restore-keys: ${{ runner.os }}-node_modules
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn install
- name: Save "node_modules" to cache
if: steps.cache.outputs.cache-hit != 'true'
uses: martijnhols/actions-cache/save@main
with:
path: node_modules
key: ${{ steps.cache.outputs.primary-key }}
build:
needs: [install]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Restore "node_modules" from cache
uses: martijnhols/actions-cache/restore@main
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock', 'patches') }}
# Fail when the cache could not be found (this should never happen unless you have a misconfiguration)
required: true
- name: Build app
run: yarn build |
Contributor
|
Hey all, 👋🏽 We have created a discussion with a proposal that will solve this problem, do let us know your feedback, thanks 😊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
read-onlyistrue, the cache is only restored and not saved. This allows for sharing the cache with multiple steps even if these steps may change them. I tried to useinputs.read-onlyin thepost-ifsince just starting the post-job takes precious seconds, but that always seems to benull.Available as
martijnhols/cache@read-onlyFixes #350, #334 and maybe #210