From f86006b16a84308e9b5048d611fe6a608eb5a05c Mon Sep 17 00:00:00 2001 From: Zhe Sun <31067185+ZheSun88@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:35:08 +0200 Subject: [PATCH] update condition to run npm ci (#3139) --- .github/actions/setup/action.yml | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 4d7d3d26da..9e88746a37 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -33,7 +33,30 @@ runs: node_modules packages/ts/*/node_modules key: ${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }} - - name: Install npm dependencies - if: ${{ steps.cache-node_modules.outputs.cache-hit != 'true' }} + - name: Get all changed package*.json files + id: changed-package-json-files + uses: tj-actions/changed-files@v45 + with: + files: | + package.json + packages/ts/*/package.json + + - name: List all changed json files + if: steps.changed-package-json-files.outputs.any_changed == 'true' + env: + ALL_CHANGED_FILES: ${{ steps.changed-package-json-files.outputs.all_changed_files }} + shell: bash + run: | + for file in ${ALL_CHANGED_FILES}; do + echo "$file was changed" + done + + - name: Install npm dependencies when no changes on package json + if: ${{ steps.cache-node_modules.outputs.cache-hit != 'true' && steps.changed-package-json-files.outputs.any_changed != 'true' }} shell: bash run: npm ci + + - name: Install npm dependencies when there are changes on package json + if: ${{ steps.changed-package-json-files.outputs.any_changed == 'true' }} + shell: bash + run: npm install