| 1 | name: Caching |
| 2 | on: push |
| 3 | jobs: |
| 4 | build: |
| 5 | runs-on: ubuntu-latest |
| 6 | steps: |
| 7 | - uses: actions/checkout@v4 |
| 8 | - name: Cache node modules |
| 9 | id: cache-npm |
| 10 | uses: actions/cache@v4 |
| 11 | env: |
| 12 | cache-name: cache-node-modules |
| 13 | with: |
| 14 | path: ~/.npm |
| 15 | key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
| 16 | restore-keys: | |
| 17 | ${{ runner.os }}-build-${{ env.cache-name }}- |
| 18 | ${{ runner.os }}-build- |
| 19 | ${{ runner.os }}- |
| 20 | - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} |
| 21 | name: List the state of node modules |
| 22 | continue-on-error: true |
| 23 | run: npm list |
| 24 | - uses: actions/cache/restore@v4 |
| 25 | with: |
| 26 | path: dist |
| 27 | key: dist-${{ github.sha }} |
| 28 | - uses: actions/cache/save@v4 |
| 29 | with: |
| 30 | path: dist |
| 31 | key: dist-${{ github.sha }} |