Add read-only feature by MartijnHols · Pull Request #474 · actions/cache
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. I tried to use inputs.read-only in the post-if since just starting the post-job takes precious seconds, but that always seems to be null.
Available as martijnhols/cache@read-only
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.
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
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