Skip to content

Commit 5ca8765

Browse files
committed
updates readme for v4
1 parent 346f2c5 commit 5ca8765

1 file changed

Lines changed: 55 additions & 16 deletions

File tree

README.md

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ See [Matching a cache key](https://help.github.com/en/actions/configuring-and-ma
3232

3333
### Example workflow
3434

35+
#### Restoring and saving cache using a single action:
36+
3537
```yaml
3638
name: Caching Primes
3739

@@ -42,24 +44,61 @@ jobs:
4244
runs-on: puzl-ubuntu-latest
4345

4446
steps:
45-
- uses: actions/checkout@v3
47+
- uses: actions/checkout@v4
4648

47-
- name: Cache Primes
48-
id: cache-primes
49-
uses: puzl-cloud/github-actions-cache@v3
50-
with:
51-
path: prime-numbers
52-
key: ${{ runner.os }}-primes
49+
- name: Cache Primes
50+
id: cache-primes
51+
uses: puzl-cloud/github-actions-cache@v4
52+
with:
53+
path: prime-numbers
54+
key: ${{ runner.os }}-primes
5355

54-
- name: Generate Prime Numbers
55-
if: steps.cache-primes.outputs.cache-hit != 'true'
56-
run: /generate-primes.sh -d prime-numbers
56+
- name: Generate Prime Numbers
57+
if: steps.cache-primes.outputs.cache-hit != 'true'
58+
run: /generate-primes.sh -d prime-numbers
5759

58-
- name: Use Prime Numbers
59-
run: /primes.sh -d prime-numbers
60+
- name: Use Prime Numbers
61+
run: /primes.sh -d prime-numbers
6062
```
6163
62-
> Note: You must use the `cache` action in your workflow before you need to use the files that might be restored from the cache. If the provided `key` matches an existing cache, a new cache is not created and if the provided `key` doesn't match an existing cache, a new cache is automatically created provided the job completes successfully.
64+
#### Using a combination of restore and save actions
65+
66+
```yaml
67+
name: Caching Primes
68+
69+
on: push
70+
71+
jobs:
72+
build:
73+
runs-on: ubuntu-latest
74+
75+
steps:
76+
- uses: actions/checkout@v4
77+
78+
- name: Restore cached Primes
79+
id: cache-primes-restore
80+
uses: puzl-cloud/github-actions-cache/restore@v4
81+
with:
82+
path: |
83+
path/to/dependencies
84+
some/other/dependencies
85+
key: ${{ runner.os }}-primes
86+
.
87+
. //intermediate workflow steps
88+
.
89+
- name: Save Primes
90+
id: cache-primes-save
91+
uses: puzl-cloud/github-actions-cache/save@v4
92+
with:
93+
path: |
94+
path/to/dependencies
95+
some/other/dependencies
96+
key: ${{ steps.cache-primes-restore.outputs.cache-primary-key }}
97+
```
98+
99+
> Note You must use the cache or restore action in your workflow before you need to use the files that might be restored
100+
> from the cache. If the provided key matches an existing cache, a new cache is not created and if the provided key
101+
> doesn't match an existing cache, a new cache is automatically created provided the job completes successfully.
63102
64103
## Creating a cache key
65104
@@ -68,7 +107,7 @@ A cache key can include any of the contexts, functions, literals, and operators
68107
For example, using the [`hashFiles`](https://docs.github.com/en/actions/learn-github-actions/expressions#hashfiles) function allows you to create a new cache when dependencies change.
69108

70109
```yaml
71-
- uses: puzl-cloud/github-actions-cache@v3
110+
- uses: puzl-cloud/github-actions-cache@v4
72111
with:
73112
path: |
74113
path/to/dependencies
@@ -101,9 +140,9 @@ Using the `cache-hit` output, subsequent steps (such as install or build) can be
101140
Example:
102141
```yaml
103142
steps:
104-
- uses: actions/checkout@v3
143+
- uses: actions/checkout@v4
105144
106-
- uses: puzl-cloud/github-actions-cache@v3
145+
- uses: puzl-cloud/github-actions-cache@v4
107146
id: cache
108147
with:
109148
path: path/to/dependencies

0 commit comments

Comments
 (0)