Skip to content

Conversation

jongwooo
Copy link

Description

Updated workflows to cache dependencies using actions/setup-node. setup-node@v3 or newer has caching built-in.

About caching workflow dependencies

Jobs on GitHub-hosted runners start in a clean virtual environment and must download dependencies each time, causing increased network utilization, longer runtime, and increased cost. To help speed up the time it takes to recreate files like dependencies, GitHub can cache files that frequently use in workflows.

Solutions

Node.js projects can run faster on GitHub Actions by enabling dependency caching on the setup-node action.

AS-IS

- uses: actions/setup-node@v3
  with:
    node-version: 'lts/*'

TO-BE

- uses: actions/setup-node@v3
  with:
    node-version: 'lts/*'
    cache: 'npm'

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

References

Checklist

  • the pull request title describes what this PR does (not a vague title like Update index.md)
  • the pull request targets the default branch of the repository (develop)
  • the code follows the established code style of the repository
    • npm run prettier:check passes
    • npm run lint:check passes
  • tests are added for the changes I made (if any source code was modified)
  • documentation added or updated
  • I have run the project locally and verified that there are no errors

@jongwooo jongwooo force-pushed the build/use-setup-node-action-to-cache-dependencies branch from 936531c to 28ae294 Compare January 25, 2023 18:16
braaar
braaar previously approved these changes Feb 1, 2023
@braaar braaar requested a review from NoNameProvided February 1, 2023 06:38
@jongwooo jongwooo force-pushed the build/use-setup-node-action-to-cache-dependencies branch from 28ae294 to d02b8fb Compare February 1, 2023 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants