- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.5k
Open
Labels
feature requestNew feature or request to improve the current logicNew feature or request to improve the current logic
Description
Description:
In their docs, actions/cache documents a workflow where you use the GitHub CLI to manually delete caches so that your caches on main don't end up being removed.
If cache-primary-key and cache-matched-key outputs were added to match actions/cache/restore (see its action.yml), users could add an optional step to delete the previous cache.
https://github.com/actions/cache/blob/main/tips-and-workarounds.md
steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-node@v4
    id: node
    with:
      cache: yarn
  - name: Cleanup previous Node cache
    if: steps.node.outputs.cache-primary-key != steps.node.outputs.cache-matched-key
    env:
      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    run: |
      gh extension install actions/gh-actions-cache
      
      REPO=${{ github.repository }}
      BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge
      gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
Justification:
Like #1151 this would give users more flexibility around caching without having to opt out the caching from actions/setup-node.
Are you willing to submit a PR?
If I can find the time
Resources
- Some context around the behaviour of the cache-hitoutput ofactions/cacheand what would be best in the next major version. Cache-Hit set to string, not boolean, as of v4.1.0 cache#1466
Metadata
Metadata
Assignees
Labels
feature requestNew feature or request to improve the current logicNew feature or request to improve the current logic