mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 13:29:10 +08:00 
			
		
		
		
	update documentation to use <action>@v4
This commit is contained in:
		@@ -23,7 +23,7 @@ If you are using separate jobs for generating common artifacts and sharing them
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
steps:
 | 
			
		||||
  - uses: actions/checkout@v3
 | 
			
		||||
  - uses: actions/checkout@v4
 | 
			
		||||
 | 
			
		||||
  - name: Install Dependencies
 | 
			
		||||
    run: /install.sh
 | 
			
		||||
@@ -31,7 +31,7 @@ steps:
 | 
			
		||||
  - name: Build artifacts
 | 
			
		||||
    run: /build.sh
 | 
			
		||||
 | 
			
		||||
  - uses: actions/cache/save@v3
 | 
			
		||||
  - uses: actions/cache/save@v4
 | 
			
		||||
    id: cache
 | 
			
		||||
    with:
 | 
			
		||||
      path: path/to/dependencies
 | 
			
		||||
@@ -47,7 +47,7 @@ Let's say we have a restore step that computes a key at runtime.
 | 
			
		||||
#### Restore a cache
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
uses: actions/cache/restore@v3
 | 
			
		||||
uses: actions/cache/restore@v4
 | 
			
		||||
id: restore-cache
 | 
			
		||||
with:
 | 
			
		||||
    key: cache-${{ hashFiles('**/lockfiles') }}
 | 
			
		||||
@@ -55,7 +55,7 @@ with:
 | 
			
		||||
 | 
			
		||||
#### Case 1 - Where a user would want to reuse the key as it is
 | 
			
		||||
```yaml
 | 
			
		||||
uses: actions/cache/save@v3
 | 
			
		||||
uses: actions/cache/save@v4
 | 
			
		||||
with:
 | 
			
		||||
    key: ${{ steps.restore-cache.outputs.cache-primary-key }}
 | 
			
		||||
```
 | 
			
		||||
@@ -63,7 +63,7 @@ with:
 | 
			
		||||
#### Case 2 - Where the user would want to re-evaluate the key
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
uses: actions/cache/save@v3
 | 
			
		||||
uses: actions/cache/save@v4
 | 
			
		||||
with:
 | 
			
		||||
    key: npm-cache-${{hashfiles(package-lock.json)}}
 | 
			
		||||
```
 | 
			
		||||
@@ -74,13 +74,13 @@ There are instances where some flaky test cases would fail the entire workflow a
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
steps:
 | 
			
		||||
  - uses: actions/checkout@v3
 | 
			
		||||
  - uses: actions/checkout@v4
 | 
			
		||||
  .
 | 
			
		||||
  . // restore if need be
 | 
			
		||||
  .
 | 
			
		||||
  - name: Build
 | 
			
		||||
    run: /build.sh
 | 
			
		||||
  - uses: actions/cache/save@v3
 | 
			
		||||
  - uses: actions/cache/save@v4
 | 
			
		||||
    if: always() // or any other condition to invoke the save action
 | 
			
		||||
    with:
 | 
			
		||||
      path: path/to/dependencies
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user