Browse Source

cache with date suffix key

Yuki Takei 6 years ago
parent
commit
5d1764766b
1 changed files with 12 additions and 2 deletions
  1. 12 2
      .github/workflows/ci.yml

+ 12 - 2
.github/workflows/ci.yml

@@ -189,13 +189,23 @@ jobs:
       uses: actions/setup-node@v1
       with:
         node-version: ${{ matrix.node-version }}
+    - name: Get Date
+      run: |
+        echo ::set-env name=DateYmdHM::$(date '+%Y%m%d%H%M')
+        echo ::set-env name=DateYmdH::$(date '+%Y%m%d%H')
+        echo ::set-env name=DateYmd::$(date '+%Y%m%d')
+        echo ::set-env name=DateYm::$(date '+%Y%m')
+        echo ::set-env name=DateY::$(date '+%Y')
     - name: Cache/Restore node_modules/.cache
       uses: actions/cache@v1
       with:
         path: node_modules/.cache
-        key: ${{ runner.OS }}-node_modules_cache-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
+        key: ${{ runner.OS }}-node_modules_cache-${{ matrix.node-version }}-${{ env.DateYmdHM }}
         restore-keys: |
-          ${{ runner.os }}-node_modules_cache-${{ matrix.node-version }}-
+          ${{ runner.os }}-node_modules_cache-${{ matrix.node-version }}-${{ env.DateYmdH }}
+          ${{ runner.os }}-node_modules_cache-${{ matrix.node-version }}-${{ env.DateYmd }}
+          ${{ runner.os }}-node_modules_cache-${{ matrix.node-version }}-${{ env.DateYm }}
+          ${{ runner.os }}-node_modules_cache-${{ matrix.node-version }}-${{ env.DateY }}
     - name: Get yarn cache dir
       id: cache-yarn
       run: echo "::set-output name=dir::$(yarn cache dir)"