Interview Prep/GitHub Actions/Caching, Artifacts, Runners & ARC

How do `actions/cache/restore` and `actions/cache/save` help?

AdvancedConceptCaching, Artifacts, Runners & ARC
Answer

They split the combined action so you control when and what is saved:

- uses: actions/cache/restore@v4
  id: restore
  with:
    path: .turbo
    key: turbo-${{ github.ref_name }}-${{ github.sha }}
    restore-keys: turbo-${{ github.ref_name }}-
- run: npx turbo run build
- if: github.ref == 'refs/heads/main'
  uses: actions/cache/save@v4
  with:
    path: .turbo
    key: ${{ steps.restore.outputs.cache-primary-key }}

Typical uses: save only on main to limit cache churn, save even when tests fail, or save a cache built in a matrix leg only once.

All GitHub Actions questions Roadmap: GitHub Actions

More on Caching, Artifacts, Runners & ARC