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
Copy file name to clipboardExpand all lines: caching-strategies.md
+21-21Lines changed: 21 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ This document lists some of the strategies (and example workflows if possible) w
12
12
jobs:
13
13
build:
14
14
runs-on: ubuntu-latest
15
-
- uses: actions/cache@v3
15
+
- uses: actions/cache@v4
16
16
with:
17
17
key: ${{ some-metadata }}-cache
18
18
```
@@ -24,7 +24,7 @@ In your workflows, you can use different strategies to name your key depending o
24
24
One of the most common use case is to use hash for lockfile as key. This way, same cache will be restored for a lockfile until there's a change in dependencies listed in lockfile.
25
25
26
26
```yaml
27
-
- uses: actions/cache@v3
27
+
- uses: actions/cache@v4
28
28
with:
29
29
path: |
30
30
path/to/dependencies
@@ -37,7 +37,7 @@ One of the most common use case is to use hash for lockfile as key. This way, sa
37
37
If cache is not found matching the primary key, restore keys can be used to download the closest matching cache that was recently created. This ensures that the build/install step will need to additionally fetch just a handful of newer dependencies, and hence saving build time.
38
38
39
39
```yaml
40
-
- uses: actions/cache@v3
40
+
- uses: actions/cache@v4
41
41
with:
42
42
path: |
43
43
path/to/dependencies
@@ -54,7 +54,7 @@ The restore keys can be provided as a complete name, or a prefix, read more [her
54
54
In case of workflows with matrix running for multiple Operating Systems, the caches can be stored separately for each of them. This can be used in combination with hashfiles in case multiple caches are being generated per OS.
55
55
56
56
```yaml
57
-
- uses: actions/cache@v3
57
+
- uses: actions/cache@v4
58
58
with:
59
59
path: |
60
60
path/to/dependencies
@@ -73,7 +73,7 @@ Caches scoped to the particular workflow run id or run attempt can be stored and
73
73
On similar lines, commit sha can be used to create a very specialized and short lived cache.
74
74
75
75
```yaml
76
-
- uses: actions/cache@v3
76
+
- uses: actions/cache@v4
77
77
with:
78
78
path: |
79
79
path/to/dependencies
@@ -86,7 +86,7 @@ On similar lines, commit sha can be used to create a very specialized and short
86
86
Cache key can be formed by combination of more than one metadata, evaluated info.
87
87
88
88
```yaml
89
-
- uses: actions/cache@v3
89
+
- uses: actions/cache@v4
90
90
with:
91
91
path: |
92
92
path/to/dependencies
@@ -146,9 +146,9 @@ In case you are using a centralized job to create and save your cache that can b
146
146
147
147
```yaml
148
148
steps:
149
-
- uses: actions/checkout@v3
149
+
- uses: actions/checkout@v4
150
150
151
-
- uses: actions/cache/restore@v3
151
+
- uses: actions/cache/restore@v4
152
152
id: cache
153
153
with:
154
154
path: path/to/dependencies
@@ -171,9 +171,9 @@ You can use the output of this action to exit the workflow on cache miss. This w
171
171
172
172
```yaml
173
173
steps:
174
-
- uses: actions/checkout@v3
174
+
- uses: actions/checkout@v4
175
175
176
-
- uses: actions/cache/restore@v3
176
+
- uses: actions/cache/restore@v4
177
177
id: cache
178
178
with:
179
179
path: path/to/dependencies
@@ -194,7 +194,7 @@ steps:
194
194
If you want to avoid re-computing the cache key again in `save` action, the outputs from `restore` action can be used as input to the `save` action.
195
195
196
196
```yaml
197
-
- uses: actions/cache/restore@v3
197
+
- uses: actions/cache/restore@v4
198
198
id: restore-cache
199
199
with:
200
200
path: |
@@ -204,7 +204,7 @@ If you want to avoid re-computing the cache key again in `save` action, the outp
204
204
.
205
205
.
206
206
.
207
-
- uses: actions/cache/save@v3
207
+
- uses: actions/cache/save@v4
208
208
with:
209
209
path: |
210
210
path/to/dependencies
@@ -219,7 +219,7 @@ On the other hand, the key can also be explicitly re-computed while executing th
219
219
Let's say we have a restore step that computes key at runtime
220
220
221
221
```yaml
222
-
uses: actions/cache/restore@v3
222
+
uses: actions/cache/restore@v4
223
223
id: restore-cache
224
224
with:
225
225
key: cache-${{ hashFiles('**/lockfiles') }}
@@ -228,15 +228,15 @@ with:
228
228
Case 1: Where an user would want to reuse the key as it is
0 commit comments