CI/CD execution times directly affect deployment cycles. Re-downloading node packages on every workflow build is highly inefficient. Let's configure custom caching for pnpm projects in GitHub Actions.
1. Setting up PNPM Store Path
PNPM uses a content-addressable store coordinates mechanism to reference modules. We instruct the runner pipeline to fetch the store location using pnpm store path commands, saving the output path as a dynamic workflow state variable.
2. Integration with actions/cache
We configure the actions/cache action to save and restore the store directory, using a cache key based on the lock file: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}. This ensures modules are fetched only when dependencies change.
Conclusion
Setting up pnpm store caching reduces build times by up to 60%, allowing you to push features and hotfixes to production servers in under 2 minutes.