Skip to content

Commit 81382a7

Browse files
authored
Merge pull request #1311 from todgru/todgru/v4-documentation-update
docs: update examples to v4
2 parents 57b8e40 + c4ee99a commit 81382a7

File tree

5 files changed

+81
-81
lines changed

5 files changed

+81
-81
lines changed

caching-strategies.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This document lists some of the strategies (and example workflows if possible) w
1212
jobs:
1313
build:
1414
runs-on: ubuntu-latest
15-
- uses: actions/cache@v3
15+
- uses: actions/cache@v4
1616
with:
1717
key: ${{ some-metadata }}-cache
1818
```
@@ -24,7 +24,7 @@ In your workflows, you can use different strategies to name your key depending o
2424
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.
2525
2626
```yaml
27-
- uses: actions/cache@v3
27+
- uses: actions/cache@v4
2828
with:
2929
path: |
3030
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
3737
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.
3838
3939
```yaml
40-
- uses: actions/cache@v3
40+
- uses: actions/cache@v4
4141
with:
4242
path: |
4343
path/to/dependencies
@@ -54,7 +54,7 @@ The restore keys can be provided as a complete name, or a prefix, read more [her
5454
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.
5555
5656
```yaml
57-
- uses: actions/cache@v3
57+
- uses: actions/cache@v4
5858
with:
5959
path: |
6060
path/to/dependencies
@@ -73,7 +73,7 @@ Caches scoped to the particular workflow run id or run attempt can be stored and
7373
On similar lines, commit sha can be used to create a very specialized and short lived cache.
7474
7575
```yaml
76-
- uses: actions/cache@v3
76+
- uses: actions/cache@v4
7777
with:
7878
path: |
7979
path/to/dependencies
@@ -86,7 +86,7 @@ On similar lines, commit sha can be used to create a very specialized and short
8686
Cache key can be formed by combination of more than one metadata, evaluated info.
8787
8888
```yaml
89-
- uses: actions/cache@v3
89+
- uses: actions/cache@v4
9090
with:
9191
path: |
9292
path/to/dependencies
@@ -146,9 +146,9 @@ In case you are using a centralized job to create and save your cache that can b
146146

147147
```yaml
148148
steps:
149-
- uses: actions/checkout@v3
149+
- uses: actions/checkout@v4
150150
151-
- uses: actions/cache/restore@v3
151+
- uses: actions/cache/restore@v4
152152
id: cache
153153
with:
154154
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
171171

172172
```yaml
173173
steps:
174-
- uses: actions/checkout@v3
174+
- uses: actions/checkout@v4
175175
176-
- uses: actions/cache/restore@v3
176+
- uses: actions/cache/restore@v4
177177
id: cache
178178
with:
179179
path: path/to/dependencies
@@ -194,7 +194,7 @@ steps:
194194
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.
195195

196196
```yaml
197-
- uses: actions/cache/restore@v3
197+
- uses: actions/cache/restore@v4
198198
id: restore-cache
199199
with:
200200
path: |
@@ -204,7 +204,7 @@ If you want to avoid re-computing the cache key again in `save` action, the outp
204204
.
205205
.
206206
.
207-
- uses: actions/cache/save@v3
207+
- uses: actions/cache/save@v4
208208
with:
209209
path: |
210210
path/to/dependencies
@@ -219,7 +219,7 @@ On the other hand, the key can also be explicitly re-computed while executing th
219219
Let's say we have a restore step that computes key at runtime
220220

221221
```yaml
222-
uses: actions/cache/restore@v3
222+
uses: actions/cache/restore@v4
223223
id: restore-cache
224224
with:
225225
key: cache-${{ hashFiles('**/lockfiles') }}
@@ -228,15 +228,15 @@ with:
228228
Case 1: Where an user would want to reuse the key as it is
229229

230230
```yaml
231-
uses: actions/cache/save@v3
231+
uses: actions/cache/save@v4
232232
with:
233233
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
234234
```
235235

236236
Case 2: Where the user would want to re-evaluate the key
237237

238238
```yaml
239-
uses: actions/cache/save@v3
239+
uses: actions/cache/save@v4
240240
with:
241241
key: npm-cache-${{hashfiles(package-lock.json)}}
242242
```
@@ -249,13 +249,13 @@ Similarly, `actions/cache/save` action can be conditionally used based on the ou
249249

250250
```yaml
251251
steps:
252-
- uses: actions/checkout@v3
252+
- uses: actions/checkout@v4
253253
.
254254
. // restore if need be
255255
.
256256
- name: Build
257257
run: /build.sh
258-
- uses: actions/cache/save@v3
258+
- uses: actions/cache/save@v4
259259
if: always() // or any other condition to invoke the save action
260260
with:
261261
path: path/to/dependencies
@@ -270,12 +270,12 @@ In case of multi-module projects, where the built artifact of one project needs
270270

271271
```yaml
272272
steps:
273-
- uses: actions/checkout@v3
273+
- uses: actions/checkout@v4
274274
275275
- name: Build
276276
run: ./build-parent-module.sh
277277
278-
- uses: actions/cache/save@v3
278+
- uses: actions/cache/save@v4
279279
id: cache
280280
with:
281281
path: path/to/dependencies
@@ -286,9 +286,9 @@ steps:
286286

287287
```yaml
288288
steps:
289-
- uses: actions/checkout@v3
289+
- uses: actions/checkout@v4
290290
291-
- uses: actions/cache/restore@v3
291+
- uses: actions/cache/restore@v4
292292
id: cache
293293
with:
294294
path: path/to/dependencies

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy