mirror of
https://github.com/actions/cache.git
synced 2024-11-13 17:38:05 +00:00
Fixed typos and formatting in docs (#1076)
* Removed extra code from readme examples * Formatted and fixed typos
This commit is contained in:
parent
22d3da765b
commit
e08330827d
@ -200,7 +200,7 @@ If you want to avoid re-computing the cache key again in `save` action, the outp
|
|||||||
path: |
|
path: |
|
||||||
path/to/dependencies
|
path/to/dependencies
|
||||||
some/other/dependencies
|
some/other/dependencies
|
||||||
key: ${{ steps.restore-cache.outputs.key }}
|
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Re-evaluate cache key while saving cache
|
### Re-evaluate cache key while saving cache
|
||||||
@ -221,7 +221,7 @@ Case 1: Where an user would want to reuse the key as it is
|
|||||||
```yaml
|
```yaml
|
||||||
uses: actions/cache/save@v3
|
uses: actions/cache/save@v3
|
||||||
with:
|
with:
|
||||||
key: ${{ steps.restore-cache.outputs.key }}
|
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
|
||||||
```
|
```
|
||||||
|
|
||||||
Case 2: Where the user would want to re-evaluate the key
|
Case 2: Where the user would want to re-evaluate the key
|
||||||
|
@ -21,6 +21,7 @@ The restore action restores a cache. It works similarly to the `cache` action ex
|
|||||||
`cache-hit` will be set to `true` only when cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`.
|
`cache-hit` will be set to `true` only when cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`.
|
||||||
|
|
||||||
### Environment Variables
|
### Environment Variables
|
||||||
|
|
||||||
* `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout)
|
* `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout)
|
||||||
|
|
||||||
## Use cases
|
## Use cases
|
||||||
@ -58,8 +59,8 @@ Once the cache is restored, unlike `actions/cache`, this action won't run a post
|
|||||||
|
|
||||||
In case of multi-module projects, where the built artifact of one project needs to be reused in subsequent child modules, the need to rebuild the parent module again and again with every build can be eliminated. The `actions/cache` or `actions/cache/save` action can be used to build and save the parent module artifact once, and it can be restored multiple times while building the child modules.
|
In case of multi-module projects, where the built artifact of one project needs to be reused in subsequent child modules, the need to rebuild the parent module again and again with every build can be eliminated. The `actions/cache` or `actions/cache/save` action can be used to build and save the parent module artifact once, and it can be restored multiple times while building the child modules.
|
||||||
|
|
||||||
|
|
||||||
#### Step 1 - Build the parent module and save it
|
#### Step 1 - Build the parent module and save it
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -75,6 +76,7 @@ steps:
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Step 2 - Restore the built artifact from cache using the same key and path
|
#### Step 2 - Restore the built artifact from cache using the same key and path
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -119,15 +121,14 @@ steps:
|
|||||||
|
|
||||||
## Tips
|
## Tips
|
||||||
|
|
||||||
|
### Reusing primary key and restored key in the save action
|
||||||
#### Reusing primary key and restored key in the save action
|
|
||||||
|
|
||||||
Usually you may want to use the same `key` with both `actions/cache/restore` and `actions/cache/save` actions. To achieve this, use `outputs` from the `restore` action to reuse the same primary key (or the key of the cache that was restored).
|
Usually you may want to use the same `key` with both `actions/cache/restore` and `actions/cache/save` actions. To achieve this, use `outputs` from the `restore` action to reuse the same primary key (or the key of the cache that was restored).
|
||||||
|
|
||||||
#### Using restore action outputs to make save action behave just like the cache action
|
### Using restore action outputs to make save action behave just like the cache action
|
||||||
|
|
||||||
The outputs `cache-primary-key` and `cache-matched-key` can be used to check if the restored cache is same as the given primary key. Alternatively, the `cache-hit` output can also be used to check if the restored was a complete match or a partially restored cache.
|
The outputs `cache-primary-key` and `cache-matched-key` can be used to check if the restored cache is same as the given primary key. Alternatively, the `cache-hit` output can also be used to check if the restored was a complete match or a partially restored cache.
|
||||||
|
|
||||||
#### Ensuring proper restores and save happen across the actions
|
### Ensuring proper restores and save happen across the actions
|
||||||
|
|
||||||
It is very important to use the same `key` and `path` that were used by either `actions/cache` or `actions/cache/save` while saving the cache. Learn more about cache key [naming](https://github.com/actions/cache#creating-a-cache-key) and [versioning](https://github.com/actions/cache#cache-version) here.
|
It is very important to use the same `key` and `path` that were used by either `actions/cache` or `actions/cache/save` while saving the cache. Learn more about cache key [naming](https://github.com/actions/cache#creating-a-cache-key) and [versioning](https://github.com/actions/cache#cache-version) here.
|
||||||
|
@ -26,10 +26,9 @@ steps:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
|
||||||
run: /install.sh
|
run: /install.sh
|
||||||
|
|
||||||
- name: Build common artifacts
|
- name: Build artifacts
|
||||||
run: /build.sh
|
run: /build.sh
|
||||||
|
|
||||||
- uses: actions/cache/save@v3
|
- uses: actions/cache/save@v3
|
||||||
|
Loading…
Reference in New Issue
Block a user