Skip to content

Commit 581312b

Browse files
author
Aiqiao Yan
committed
Update readme and examples to use v2
1 parent 9ab9538 commit 581312b

File tree

2 files changed

+120
-71
lines changed

2 files changed

+120
-71
lines changed

README.md

+61-6
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,67 @@ 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
12+
13+
* Added support for caching multiple paths,
14+
15+
```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
26+
uses: actions/cache@v2
27+
with:
28+
path: |
29+
~/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
42+
**/node_modules
43+
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
44+
```
45+
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`
60+
* Released the [`@actions/cache`](https://github.com/actions/toolkit/tree/master/packages/cache) npm package to allow other actions to utilize caching
61+
* Added a best-effort cleanup step to delete the archive after extraction to reduce storage space
62+
1163
## Usage
1264

1365
### Pre-requisites
1466
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).
1567

1668
### Inputs
1769

18-
* `path` - A directory to store and save the cache
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.
1972
* `key` - An explicit key for restoring and saving the cache
2073
* `restore-keys` - An ordered list of keys to use for restoring the cache if no cache hit occurred for key
2174

@@ -46,7 +99,7 @@ jobs:
4699
47100
- name: Cache Primes
48101
id: cache-primes
49-
uses: actions/cache@v1
102+
uses: actions/cache@v2
50103
with:
51104
path: prime-numbers
52105
key: ${{ runner.os }}-primes
@@ -93,9 +146,11 @@ A cache key can include any of the contexts, functions, literals, and operators
93146
For example, using the [`hashFiles`](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#hashfiles) function allows you to create a new cache when dependencies change.
94147

95148
```yaml
96-
- uses: actions/cache@v1
149+
- uses: actions/cache@v2
97150
with:
98-
path: path/to/dependencies
151+
path: |
152+
path/to/dependencies
153+
some/other/dependencies
99154
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
100155
```
101156

@@ -109,7 +164,7 @@ Additionally, you can use arbitrary command output in a cache key, such as a dat
109164
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
110165
shell: bash
111166
112-
- uses: actions/cache@v1
167+
- uses: actions/cache@v2
113168
with:
114169
path: path/to/dependencies
115170
key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/lockfiles') }}
@@ -130,7 +185,7 @@ Example:
130185
steps:
131186
- uses: actions/checkout@v2
132187
133-
- uses: actions/cache@v1
188+
- uses: actions/cache@v2
134189
id: cache
135190
with:
136191
path: path/to/dependencies

0 commit comments

Comments
 (0)