From 3b1034f30324e1e6c6d70df3225cedb3d9779a24 Mon Sep 17 00:00:00 2001 From: yaswanth-deriv <121096908+yaswanth-deriv@users.noreply.github.com> Date: Tue, 24 Oct 2023 11:44:01 +0400 Subject: [PATCH] refactor: to add node from cache --- .github/actions/npm_install/action.yml | 9 --------- .../actions/npm_install_from_cache/action.yml | 17 +++++++++++++++++ .github/workflows/release_production.yml | 2 +- .github/workflows/release_staging.yml | 2 +- .github/workflows/test.yml | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) delete mode 100644 .github/actions/npm_install/action.yml create mode 100644 .github/actions/npm_install_from_cache/action.yml diff --git a/.github/actions/npm_install/action.yml b/.github/actions/npm_install/action.yml deleted file mode 100644 index a9a1e8fe..00000000 --- a/.github/actions/npm_install/action.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: npm_install -description: Install NPM packages -runs: - steps: - - name: Install npm packages - run: |- - npm ci - npm run format - shell: bash diff --git a/.github/actions/npm_install_from_cache/action.yml b/.github/actions/npm_install_from_cache/action.yml new file mode 100644 index 00000000..f96eeb4e --- /dev/null +++ b/.github/actions/npm_install_from_cache/action.yml @@ -0,0 +1,17 @@ +name: npm_install_from_cache +description: Install npm packages from cache +runs: + using: composite + steps: + - name: Cache node modules + id: cache-nodemodules + uses: actions/cache/restore@v3 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('./package-lock.json') }} + - name: Install npm dependencies + if: steps.cache-nodemodules.outputs.cache-hit != 'true' + run: |- + npm ci + npm run format + shell: bash diff --git a/.github/workflows/release_production.yml b/.github/workflows/release_production.yml index 9248243f..74c61d58 100644 --- a/.github/workflows/release_production.yml +++ b/.github/workflows/release_production.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Install npm packages - uses: "./.github/actions/npm_install" + uses: "./.github/actions/npm_install_from_cache" - name: Build uses: "./.github/actions/build" with: diff --git a/.github/workflows/release_staging.yml b/.github/workflows/release_staging.yml index ca822ce6..5562e7bb 100644 --- a/.github/workflows/release_staging.yml +++ b/.github/workflows/release_staging.yml @@ -14,7 +14,7 @@ jobs: - name: Tag uses: "./.github/actions/tag" - name: Install npm packages - uses: "./.github/actions/npm_install" + uses: "./.github/actions/npm_install_from_cache" - name: Build uses: "./.github/actions/build" with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fc1f3e59..ced11a65 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Install npm packages - uses: "./.github/actions/npm_install" + uses: "./.github/actions/npm_install_from_cache" - name: Build uses: "./.github/actions/build"