From a297c9d0ccb5080e26ae90f8eab076bfdac22ca1 Mon Sep 17 00:00:00 2001 From: Bobby Date: Fri, 6 May 2022 22:29:15 +0700 Subject: [PATCH] ci: fix node_modules caching https://github.com/actions/setup-node/issues/416 --- .github/workflows/deploy.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1d5272d..479b6e5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,6 +11,9 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: +env: + NODE_VERSION: 14 + # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "build" @@ -27,11 +30,18 @@ jobs: - name: Install Node v14 uses: actions/setup-node@v3 with: - node-version: '14' - cache: 'yarn' + node-version: ${{ env.NODE_VERSION }} + + - name: Cache node_modules + uses: actions/cache@v2 + id: cache-nodemodules + with: + path: node_modules + key: ${{ runner.os }}-${{ env.NODE_VERSION }}-nodemodules-${{ hashFiles('**/yarn.lock') }} - name: Install dependencies - run: yarn install + if: steps.cache-nodemodules.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile --non-interactive - name: Build application run: yarn build