1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-04-02 04:57:46 +02:00

Added info about key and restore keys

This commit is contained in:
Sankalp Kotewar 2023-01-04 08:00:31 +00:00 committed by GitHub
parent 5e6197bef2
commit f8cf48dd94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,7 @@ The cache action works using the following set of inputs and outputs as mentione
### Keys
A `key`, also referred as `primary key` is a value with which cache is restored or saved. If cache is not found with the primary key, the same key is used to save the cache in the `actions/cache` action.
#### Static keys
```yaml
@ -56,6 +57,12 @@ Cache key by combination of multiple options:
The [GitHub Context](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context) can be used to create keys using the workflows metadata.
### Restore keys
Restore keys are a set of keys that are looked for when cache with primary key is not found. The first matching cache is downloaded when restore keys are provided.
The restore keys can be provided as a complete name, or a prefix, read more [here](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key) on how a cache key is matched using restore keys.
### Paths
The path(s) in the cache action define(s) the path/directory that needs to be cached. The directory can reside on the runner or containers inside runners. The path to dependencies can either be a fix path or a glob pattern that's matched with existing directory structure and evaluated at runtime. Refer [@actions/glob](https://github.com/actions/toolkit/tree/main/packages/glob#patterns) to get more information about the patterns.
@ -82,10 +89,26 @@ Refer [matching the key](https://docs.github.com/en/actions/using-workflows/cach
## Cache action
The cache action allows caching dependencies and build outputs to improve workflow execution time.
It has a `main` step and a `post` step. In the `main` step, the cache is restored if it exists for the input `key`, `path` combination (refer [scope](#scope)). If the cache doesn't exist or a partial match is found, the cache is saved in the `post` step.
**Usage**
```yaml
- uses: actions/cache@v3
```
### Sample workflow for cache action
## Restore action
**Usage**
```yaml
- uses: actions/cache/restore@v3
```
### Sample workflow for restore action
<!-- Explain how the outputs differ depending on caches found, not found or partially found -->
@ -95,6 +118,12 @@ Refer [matching the key](https://docs.github.com/en/actions/using-workflows/cach
## Save action
**Usage**
```yaml
- uses: actions/cache/restore@v3
```
### Sample workflow for save action
<!-- Explain the different ways of taking the inputs here
Saving with hardcoded key - Basic save