yuksi
yuksi

Reputation: 107

npm version package-lock.json caching issue in GitHub Actions

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

Upvotes: 0

Views: 540

Answers (0)

Related Questions