C-hive/gha-npm-cache: 1-liner Npm Install Cache For GitHub Actions
-
Uh oh!
There was an error while loading. Please reload this page.
- Notifications You must be signed in to change notification settings
- Fork 5
- Star 19
- Code
- Issues 0
- Pull requests 0
- Actions
- Security 0
- Insights
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Latest commitHistory73 Commits | ||||
| .github | .github | |||
| .vscode | .vscode | |||
| dist | dist | |||
| src | src | |||
| .editorconfig | .editorconfig | |||
| .eslintignore | .eslintignore | |||
| .eslintrc.js | .eslintrc.js | |||
| .gitignore | .gitignore | |||
| .npmrc | .npmrc | |||
| .prettierrc.js | .prettierrc.js | |||
| LICENSE | LICENSE | |||
| README.md | README.md | |||
| action.yml | action.yml | |||
| package-lock.json | package-lock.json | |||
| package.json | package.json | |||
| View all files | ||||
Repository files navigation
- README
- MIT license
Deprecated
This functionality is now part of actions/setup-node:
- name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '16' cache: 'npm' gha-npm-cache1-liner npm install cache for GitHub Actions
Status and support
- ✔ stable
- ✖ not supported
- ✖ no ongoing development
GitHub Action caches improve build times and reduce network dependencies. However, writing the correct cache logic is tricky. You need to understand how the cache action (keys and restore keys) work. Did you know you're not supposed to cache the node_modules folder? The setup is different per OS and takes a lot of space in your workflows. Not anymore!
gha-npm-cache is a simple 1-liner that covers all use-cases, correctly:
- Caches the NPM cache directory instead of node-modules as recommended
- Works on Ubuntu, MacOS and Windows
- Restore keys take the OS into account as recommended
- Builds on the native cache functionality of GitHub Actions, same as v2 of the generic cache action
Usage
Add this step before npm install:
- uses: c-hive/gha-npm-cache@v1For example:
.github/workflows/ci.yml
name: CI on: [push] jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: c-hive/gha-npm-cache@v1 # with: # directory: server # Optional, specify the folder of package-lock.json if not in the root directory - name: Install JS dependencies run: npm install - name: Test run: npm run testSolution comparison
Native
- name: Get npm cache directory id: npm-cache run: | echo "::set-output name=dir::$(npm config get cache)" - uses: actions/cache@v1 with: path: ${{ steps.npm-cache.outputs.dir }} key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node-gha-npm-cache
- uses: c-hive/gha-npm-cache@v1Similar actions
- gha-yarn-cache
Conventions
This project follows C-Hive guides for code style, way of working and other development concerns.
License
The project is available as open source under the terms of the MIT License.
About
1-liner npm install cache for GitHub Actions
Resources
ReadmeLicense
MIT licenseUh oh!
There was an error while loading. Please reload this page.
Activity Custom propertiesStars
19 starsWatchers
2 watchingForks
5 forks Report repositoryReleases 1
v1 Latest May 21, 2020Sponsor this project
SponsorUh oh!
There was an error while loading. Please reload this page.
Learn more about GitHub SponsorsPackages 0
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Contributors
Uh oh!
There was an error while loading. Please reload this page.
Languages
- JavaScript 100.0%
Tag » C Npm
-
C
-
Npm
-
C - Npm Package Health Analysis - Snyk
-
What Is Npm - W3Schools
-
Manage Npm Packages - Visual Studio (Windows) | Microsoft Docs
-
Dependencies | Node.js
-
Npm Install Command Failing With Message "could Not Find Visual ...
-
Message "npm WARN Config Global `--global`, `--local` Are ...
-
NPM - Node Package Manager - TutorialsTeacher
-
Difference Between Npm I And Npm Ci In Node.js - GeeksforGeeks
-
Appendix C. Using The Npm Package Manager - LiveBook · Manning
-
Install NPM On Debian 9 - Linux Hint