mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 15:48:39 +08:00 
			
		
		
		
	Use different IDs for 1) getting the directory of yarn cache 2) the cache itself
Using the current example + https://github.com/actions/cache#skipping-steps-based-on-cache-hit, I came to a wrong conclusion that I could skip a step if the `cache-hit` was `true` - the ID I used was from the wrong step - the `get yarn cache directory` step, instead of the `get yarn cache itself` step. I've updated the example in hopes that it'll be clearer for others aswell! Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
This commit is contained in:
		
							parent
							
								
									78a4b2143b
								
							
						
					
					
						commit
						82069170eb
					
				
							
								
								
									
										12
									
								
								examples.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								examples.md
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -140,7 +140,7 @@ For npm, cache files are stored in `~/.npm` on Posix, or `%AppData%/npm-cache` o
 | 
			
		|||
 | 
			
		||||
### Using multiple systems and `npm config`
 | 
			
		||||
 | 
			
		||||
```yaml  
 | 
			
		||||
```yaml
 | 
			
		||||
- name: Get npm cache directory
 | 
			
		||||
  id: npm-cache
 | 
			
		||||
  run: |
 | 
			
		||||
| 
						 | 
				
			
			@ -157,21 +157,23 @@ For npm, cache files are stored in `~/.npm` on Posix, or `%AppData%/npm-cache` o
 | 
			
		|||
The yarn cache directory will depend on your operating system and version of `yarn`. See https://yarnpkg.com/lang/en/docs/cli/cache/ for more info.
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- name: Get yarn cache
 | 
			
		||||
  id: yarn-cache
 | 
			
		||||
- name: Get yarn cache directory path
 | 
			
		||||
  id: yarn-cache-dir-path
 | 
			
		||||
  run: echo "::set-output name=dir::$(yarn cache dir)"
 | 
			
		||||
 | 
			
		||||
- uses: actions/cache@v1
 | 
			
		||||
  id: yarn-cache
 | 
			
		||||
  with:
 | 
			
		||||
    path: ${{ steps.yarn-cache.outputs.dir }}
 | 
			
		||||
    path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
 | 
			
		||||
    key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
 | 
			
		||||
    restore-keys: |
 | 
			
		||||
      ${{ runner.os }}-yarn-
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## PHP - Composer
 | 
			
		||||
 | 
			
		||||
```yaml  
 | 
			
		||||
```yaml
 | 
			
		||||
- name: Get Composer Cache Directory
 | 
			
		||||
  id: composer-cache
 | 
			
		||||
  run: |
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user