chore: Use built-in cache action to cache dependencies by jongwooo · Pull Request #1014 · actions/cache

Signed-off-by: jongwooo jongwooo.han@gmail.com

Description

Use built-in cache action to cache dependencies at workflow.yml.
See actions/cache#1004.

AS-IS

- name: Setup Node.js 16.x
  uses: actions/setup-node@v3
  with:
    node-version: 16.x
- name: Determine npm cache directory
  id: npm-cache
  run: |
    echo "::set-output name=dir::$(npm config get cache)"
- name: Restore npm cache
  uses: actions/cache@v3
  with:
    path: ${{ steps.npm-cache.outputs.dir }}
    key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
    restore-keys: |
      ${{ runner.os }}-node-

TO-BE

- name: Setup Node.js 16.x
  uses: actions/setup-node@v3
  with:
    node-version: 16.x
    cache: npm

It’s literally a one line change to pass the cache: npm input parameter.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (add or update README or docs)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.