diff --git a/.github/workflows/cache.yml b/.github/workflows/cache.yml index 7beb7c6e..cd634ceb 100644 --- a/.github/workflows/cache.yml +++ b/.github/workflows/cache.yml @@ -23,14 +23,17 @@ jobs: sparse-checkout-cone-mode: false sparse-checkout: | package.json - - name: 📥 Install deps + - id: install + name: 📥 Install deps run: yarn env: HUSKY_SKIP_INSTALL: true - - name: ♻️ Save node_modules + - if: > + always() && steps.install.outcome == 'success' + name: ♻️ Save node_modules uses: actions/cache/save@v4 with: path: | yarn.lock node_modules - key: ${{ runner.os }}-${{ hashFiles('package.json') }} + key: ${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41fe2e41..7578799b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,17 +14,32 @@ jobs: steps: - name: ⬇️ Checkout repo uses: actions/checkout@v4 - - name: ♻️ Cache node_modules - uses: actions/cache@v4 + - id: restore + name: ♻️ Restore node_modules + uses: actions/cache/restore@v4 with: path: | yarn.lock node_modules - key: ${{ runner.os }}-${{ hashFiles('package.json') }} - - name: 📥 Install deps + key: ${{ hashFiles('package.json') }} + restore-keys: ${{ hashFiles('package.json') }}- + + - id: install + if: > + steps.restore.outputs.cache-matched-key == '' + name: 📥 Install deps run: yarn env: HUSKY_SKIP_INSTALL: true + - if: > + steps.install.outcome == 'success' + name: ♻️ Save node_modules + uses: actions/cache/save@v4 + with: + path: | + yarn.lock + node_modules + key: ${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }} - name: ✍ Lint run: npm run lint