Always cache files and save them

Hello! I need cache to be restored and saved again every time the job ends. How to do this?

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
        cache-name: cache-node-modules
        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 commit, which will cause ‘cache-hit’ value is ‘false’.

Cache restored:

Cache saved:

Hope it’s clear and helpful.