mirror of
https://github.com/actions/cache.git
synced 2024-12-26 19:43:04 +07:00
Remove recommendation to cache node_modules (#69)
* Update npm caching examples * Fix output name * Remove extra details tag
This commit is contained in:
parent
bde557aefd
commit
bc821d0c12
23
README.md
23
README.md
@ -28,7 +28,7 @@ Create a workflow `.yml` file in your repositories `.github/workflows` directory
|
|||||||
### Example workflow
|
### Example workflow
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: Example Caching with npm
|
name: Caching Primes
|
||||||
|
|
||||||
on: push
|
on: push
|
||||||
|
|
||||||
@ -39,22 +39,19 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
- name: Cache node modules
|
- name: Cache Primes
|
||||||
|
id: cache-primes
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: node_modules
|
path: prime-numbers
|
||||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
key: ${{ runner.os }}-primes
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-node-
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Generate Prime Numbers
|
||||||
run: npm install
|
if: steps.cache-primes.outputs.cache-hit != 'true'
|
||||||
|
run: /generate-primes.sh -d prime-numbers
|
||||||
|
|
||||||
- name: Build
|
- name: Use Prime Numbers
|
||||||
run: npm run build
|
run: /primes.sh -d prime-numbers
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: npm run test
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ecosystem Examples
|
## Ecosystem Examples
|
||||||
|
34
examples.md
34
examples.md
@ -70,10 +70,42 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa
|
|||||||
|
|
||||||
## Node - npm
|
## Node - npm
|
||||||
|
|
||||||
|
For npm, cache files are stored in `~/.npm` on Posix, or `%AppData%/npm-cache` on Windows. See https://docs.npmjs.com/cli/cache#cache
|
||||||
|
|
||||||
|
>Note: It is not recommended to cache `node_modules`, as it can break across Node versions and won't work with `npm ci`
|
||||||
|
|
||||||
|
### macOS and Ubuntu
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/cache@v1
|
- uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: node_modules
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-
|
||||||
|
```
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~\AppData\Roaming\npm-cache
|
||||||
|
key: ${{ runner.os }}-node-${{ hashFiles('**\package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using multiple systems and `npm config`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- 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') }}
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-node-
|
${{ runner.os }}-node-
|
||||||
|
Loading…
Reference in New Issue
Block a user