mirror of
https://code.forgejo.org/actions/cache.git
synced 2024-11-27 14:39:16 +01:00
Use different IDs for 1) getting the directory of yarn cache 2) the cache itself (#178)
* 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> * Explain which ID to use for `cache-hit` in yarn's example Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
This commit is contained in:
parent
4944275b95
commit
e8230b28a9
1 changed files with 7 additions and 5 deletions
|
@ -157,18 +157,20 @@ 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.
|
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
|
```yaml
|
||||||
- name: Get yarn cache
|
- name: Get yarn cache directory path
|
||||||
id: yarn-cache
|
id: yarn-cache-dir-path
|
||||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||||
|
|
||||||
- uses: actions/cache@v1
|
- uses: actions/cache@v1
|
||||||
|
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache.outputs.dir }}
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-yarn-
|
${{ runner.os }}-yarn-
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## PHP - Composer
|
## PHP - Composer
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|
Loading…
Reference in a new issue