0

My trigger in the GitHub Actions workflow is when we have a new tag, then deploy the tag to the desired environment.

So, running npm version prerelease will trigger the workflow.

The problem is when I try to use cache I see that the version in package.json and package-lock.json are always changed so I can't use real cache here.

How can I continue working with npm version and get the benefits of caching?

   - uses: actions/checkout@v2
      - name: Cache node modules
        id: cache-nodemodules
        uses: actions/cache@v2
        env:
          cache-name: cache-node-modules-preview
        with:
          # caching node_modules
          path: node_modules
          key: ${{ runner.os }}-preview-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-preview-${{ env.cache-name }}-
            ${{ runner.os }}-preview-

      - name: Install Dependencies app
        if: steps.cache-nodemodules.outputs.cache-hit != 'true'
        run: npm ci --legacy-peer-deps

      - name: build
        run: npm run build
Azeem
  • 11,148
  • 4
  • 27
  • 40
yuksi
  • 97
  • 9
  • Are your package.json changes only because you’re chancing the project version number? If you have actual updates to packages you use, it would not make sense to cache the node_modules folder. – Rob Bos Feb 16 '23 at 07:53
  • @RobBos the cache is failed because smth was changed – yuksi Feb 20 '23 at 07:19

0 Answers0