Skip to content

Commit e6c708b

Browse files
author
Aiqiao Yan
committed
React to feedback
1 parent 581312b commit e6c708b

File tree

3 files changed

+24
-56
lines changed

3 files changed

+24
-56
lines changed

README.md

+9-40
Original file line numberDiff line numberDiff line change
@@ -8,67 +8,36 @@ This action allows caching dependencies and build outputs to improve workflow ex
88

99
See ["Caching dependencies to speed up workflows"](https://help.github.com/github/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows).
1010

11-
## What's New in V2
11+
## What's New
1212

13-
* Added support for caching multiple paths,
13+
* Added support for multiple paths, [glob patterns](https://github.com/actions/toolkit/tree/master/packages/glob), and single file caches.
1414

1515
```yaml
16-
- name: Cache multiple relative paths
17-
uses: actions/cache@v2
18-
with:
19-
path: |
20-
node_modules
21-
dist
22-
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
23-
```
24-
```yaml
25-
- name: Cache multiple absolute paths
16+
- name: Cache multiple paths
2617
uses: actions/cache@v2
2718
with:
2819
path: |
2920
~/cache
30-
/path/to/dependencies
31-
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
32-
```
33-
34-
[glob patterns](https://github.com/actions/toolkit/tree/master/packages/glob),
35-
36-
```yaml
37-
- name: Cache using glob patterns
38-
uses: actions/cache@v2
39-
with:
40-
path: |
41-
**/*.ts
21+
!~/cache/exclude
4222
**/node_modules
4323
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
4424
```
4525
46-
and single file caches.
47-
48-
```yaml
49-
- name: Cache single file
50-
uses: actions/cache@v2
51-
with:
52-
path: cache.tar
53-
key: ${{ runner.os }}
54-
```
55-
56-
* Increased perfomance and improved cache sizes using `zstd` compression
57-
> Note this feature is off for Windows runner that are using `bsdtar` (e.g., windows-latest hosted runner) due to a bug in ziping large random files with `bsdtar`
58-
* Allowed caching for all events with a ref
59-
> See [events that trigger workflow](https://help.github.com/en/actions/reference/events-that-trigger-workflows) for info on which events do not have a `GITHUB_REF`
26+
* Increased performance and improved cache sizes using `zstd` compression for Linux and macOS runners
27+
* Allowed caching for all events with a ref. See [events that trigger workflow](https://help.github.com/en/actions/reference/events-that-trigger-workflows) for info on which events do not have a `GITHUB_REF`
6028
* Released the [`@actions/cache`](https://github.com/actions/toolkit/tree/master/packages/cache) npm package to allow other actions to utilize caching
6129
* Added a best-effort cleanup step to delete the archive after extraction to reduce storage space
6230

31+
Refer [here](https://github.com/actions/cache/blob/v1/README.md) for previous versions
32+
6333
## Usage
6434

6535
### Pre-requisites
6636
Create a workflow `.yml` file in your repositories `.github/workflows` directory. An [example workflow](#example-workflow) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).
6737

6838
### Inputs
6939

70-
* `path` - Directories to store and save the cache. Supports pattern matching, multipath and single file cache
71-
> See [`@actions/glob`](https://github.com/actions/toolkit/tree/master/packages/glob) for supported patterns.
40+
* `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/master/packages/glob) for supported patterns.
7241
* `key` - An explicit key for restoring and saving the cache
7342
* `restore-keys` - An ordered list of keys to use for restoring the cache if no cache hit occurred for key
7443

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: 'Cache artifacts like dependencies and build outputs to improve wor
33
author: 'GitHub'
44
inputs:
55
path:
6-
description: 'A directory to store and save the cache'
6+
description: 'A list of files, directories, and wildcard patterns to cache and restore'
77
required: true
88
key:
99
description: 'An explicit key for restoring and saving the cache'

examples.md

+14-15
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,19 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa
4444
```
4545
4646
Depending on the environment, huge packages might be pre-installed in the global cache folder.
47-
If you do not want to include them, consider to move the cache folder like below.
47+
With `actions/cache@v2` you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/master/packages/glob#exclude-patterns)
48+
```yaml
49+
- uses: actions/cache@v2
50+
with:
51+
path: |
52+
~/.nuget/packages
53+
!~/.nuget/packages/unwanted
54+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
55+
restore-keys: |
56+
${{ runner.os }}-nuget-
57+
```
58+
59+
Or you could move the cache folder like below.
4860
>Note: This workflow does not work for projects that require files to be placed in user profile package folder
4961
```yaml
5062
env:
@@ -58,18 +70,6 @@ steps:
5870
${{ runner.os }}-nuget-
5971
```
6072

61-
With `actions/cache@v2` you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/master/packages/glob#exclude-patterns)
62-
```yaml
63-
- uses: actions/cache@v2
64-
with:
65-
path: |
66-
~/.nuget/packages
67-
!~/.nuget/packages/unwanted
68-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
69-
restore-keys: |
70-
${{ runner.os }}-nuget-
71-
```
72-
7373
## D - DUB
7474

7575
### POSIX
@@ -426,8 +426,7 @@ When dependencies are installed later in the workflow, we must specify the same
426426
## Rust - Cargo
427427

428428
```yaml
429-
- name: Cache cargo
430-
uses: actions/cache@v2
429+
- uses: actions/cache@v2
431430
with:
432431
path: |
433432
~/.cargo/registry

0 commit comments

Comments
 (0)