You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The action has a built-in functionality for caching and restoring npm/yarn dependencies. Supported package managers are `npm`, `yarn`, `pnpm`. The `cache` input is optional, and caching is turned off by default.
44
+
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional, and caching is turned off by default.
45
+
46
+
The action defaults to search for the dependency file (`package-lock.json` or `yarn.lock`) in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases when multiple dependency files are used, or they are located in different subdirectories.
47
+
48
+
See the examples of using cache for `yarn` / `pnpm` and `cache-dependency-path` input in the [Advanced usage](docs/advanced-usage.md#caching-packages-dependencies) guide.
45
49
46
50
**Caching npm dependencies:**
47
51
```yaml
@@ -55,44 +59,20 @@ steps:
55
59
- run: npm test
56
60
```
57
61
58
-
**Caching yarn dependencies:**
62
+
**Caching npm dependencies in monorepos:**
59
63
```yaml
60
64
steps:
61
65
- uses: actions/checkout@v2
62
66
- uses: actions/setup-node@v2
63
67
with:
64
68
node-version: '14'
65
-
cache: 'yarn'
66
-
- run: yarn install
67
-
- run: yarn test
68
-
```
69
-
Yarn caching handles both yarn versions: 1 or 2.
70
-
71
-
**Caching pnpm (v6.10+) dependencies:**
72
-
```yaml
73
-
# This workflow uses actions that are not certified by GitHub.
74
-
# They are provided by a third-party and are governed by
75
-
# separate terms of service, privacy policy, and support
76
-
# documentation.
77
-
78
-
# NOTE: pnpm caching support requires pnpm version >= 6.10.0
Copy file name to clipboardExpand all lines: action.yml
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@ inputs:
21
21
default: ${{ github.token }}
22
22
cache:
23
23
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm'
24
+
cache-dependency-path:
25
+
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
24
26
# TODO: add input to control forcing to pull from cloud or dist.
25
27
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
26
28
# Deprecated option, do not use. Will not be supported after October 1, 2019
Copy file name to clipboardExpand all lines: docs/advanced-usage.md
+72-6Lines changed: 72 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Advanced usage
2
2
3
-
###Check latest version:
3
+
## Check latest version
4
4
5
5
The `check-latest` flag defaults to `false`. When set to `false`, the action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/). Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Node.js is always used.
6
6
@@ -19,7 +19,7 @@ steps:
19
19
- run: npm test
20
20
```
21
21
22
-
### Architecture:
22
+
## Architecture
23
23
24
24
You can use any of the [supported operating systems](https://docs.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners), and the compatible `architecture` can be selected using `architecture`. Values are `x86`, `x64`, `arm64`, `armv6l`, `armv7l`, `ppc64le`, `s390x` (not all of the architectures are available on all platforms).
25
25
@@ -39,7 +39,73 @@ jobs:
39
39
- run: npm test
40
40
```
41
41
42
-
### Multiple Operating Systems and Architectures:
42
+
## Caching packages dependencies
43
+
The action follows [actions/cache](https://github.com/actions/cache/blob/main/examples.md#node---npm) guidelines, and caches global cache on the machine instead of `node_modules`, so cache can be reused between different Node.js versions.
44
+
45
+
**Caching yarn dependencies:**
46
+
Yarn caching handles both yarn versions: 1 or 2.
47
+
```yaml
48
+
steps:
49
+
- uses: actions/checkout@v2
50
+
- uses: actions/setup-node@v2
51
+
with:
52
+
node-version: '14'
53
+
cache: 'yarn'
54
+
- run: yarn install
55
+
- run: yarn test
56
+
```
57
+
58
+
**Caching pnpm (v6.10+) dependencies:**
59
+
```yaml
60
+
# This workflow uses actions that are not certified by GitHub.
61
+
# They are provided by a third-party and are governed by
62
+
# separate terms of service, privacy policy, and support
63
+
# documentation.
64
+
65
+
# NOTE: pnpm caching support requires pnpm version >= 6.10.0
0 commit comments