Skip to content

Always cache files and save them #26467

Discussion options

You must be logged in to vote

Hi @ghost6482 ,

When cache-hit value is false, the cache will be restored and saved again.  Code sample as below:

- name: Cache node modules
      id: cachetest
      uses: actions/cache@v1
      env:
        cache-name: cache-node-modules
      with:
        path: npm # npm cache files are stored in `npm` on Linux/macOS
        key: ${{ runner.os }}-build-${{ env.cache-name }}-${ github.sha }}-${{ hashFiles('**/package.json') }} # Add githu.sha to make the key different each time
        restore-keys: |
          ${{ runner.os }}-build-${{ env.cache-name }}-
          ${{ runner.os }}-build-
          ${{ runner.os }}-

I added ${{githu.sha}} to make sure the key is different for each co…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Build, test, and automate your deployment pipeline with world-class CI/CD Product Feedback
2 participants