From ee0068d6eaac1a38cbcf56b3e640f57798049869 Mon Sep 17 00:00:00 2001 From: Toby Hsieh Date: Tue, 4 Jul 2023 14:59:07 -0700 Subject: [PATCH] Improve node_modules caching This attempts to have the cache key derived from package-lock.json's hash. --- action.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 7f7b51d..d462916 100644 --- a/action.yml +++ b/action.yml @@ -10,13 +10,19 @@ inputs: runs: using: composite steps: + # We need to copy codemention's package-lock.json into the workspace + # because hashFiles only works on files inside the workspace. + - run: cp ${{ github.action_path }}/package-lock.json codemention-package-lock.json + shell: bash - uses: actions/cache@v3 + id: cache-node-modules with: path: ${{ github.action_path }}/node_modules - key: codemention-npm + key: codemention-npm-${{ hashFiles('codemention-package-lock.json') }} - run: npm install working-directory: ${{ github.action_path }} shell: bash + if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: npm run build working-directory: ${{ github.action_path }} shell: bash