mirror of
https://gitee.com/actions-mirror/cache.git
synced 2024-11-23 19:30:43 +08:00
React to feedback
This commit is contained in:
parent
581312be20
commit
e6c708b5ce
49
README.md
49
README.md
@ -8,58 +8,28 @@ This action allows caching dependencies and build outputs to improve workflow ex
|
|||||||
|
|
||||||
See ["Caching dependencies to speed up workflows"](https://help.github.com/github/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows).
|
See ["Caching dependencies to speed up workflows"](https://help.github.com/github/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows).
|
||||||
|
|
||||||
## What's New in V2
|
## What's New
|
||||||
|
|
||||||
* Added support for caching multiple paths,
|
* Added support for multiple paths, [glob patterns](https://github.com/actions/toolkit/tree/master/packages/glob), and single file caches.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Cache multiple relative paths
|
- name: Cache multiple paths
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
node_modules
|
|
||||||
dist
|
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
|
||||||
```
|
|
||||||
```yaml
|
|
||||||
- name: Cache multiple absolute paths
|
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/cache
|
~/cache
|
||||||
/path/to/dependencies
|
!~/cache/exclude
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
|
||||||
```
|
|
||||||
|
|
||||||
[glob patterns](https://github.com/actions/toolkit/tree/master/packages/glob),
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- name: Cache using glob patterns
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
**/*.ts
|
|
||||||
**/node_modules
|
**/node_modules
|
||||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||||
```
|
```
|
||||||
|
|
||||||
and single file caches.
|
* Increased performance and improved cache sizes using `zstd` compression for Linux and macOS runners
|
||||||
|
* Allowed caching for all events with a ref. See [events that trigger workflow](https://help.github.com/en/actions/reference/events-that-trigger-workflows) for info on which events do not have a `GITHUB_REF`
|
||||||
```yaml
|
|
||||||
- name: Cache single file
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: cache.tar
|
|
||||||
key: ${{ runner.os }}
|
|
||||||
```
|
|
||||||
|
|
||||||
* Increased perfomance and improved cache sizes using `zstd` compression
|
|
||||||
> Note this feature is off for Windows runner that are using `bsdtar` (e.g., windows-latest hosted runner) due to a bug in ziping large random files with `bsdtar`
|
|
||||||
* Allowed caching for all events with a ref
|
|
||||||
> See [events that trigger workflow](https://help.github.com/en/actions/reference/events-that-trigger-workflows) for info on which events do not have a `GITHUB_REF`
|
|
||||||
* Released the [`@actions/cache`](https://github.com/actions/toolkit/tree/master/packages/cache) npm package to allow other actions to utilize caching
|
* Released the [`@actions/cache`](https://github.com/actions/toolkit/tree/master/packages/cache) npm package to allow other actions to utilize caching
|
||||||
* Added a best-effort cleanup step to delete the archive after extraction to reduce storage space
|
* Added a best-effort cleanup step to delete the archive after extraction to reduce storage space
|
||||||
|
|
||||||
|
Refer [here](https://github.com/actions/cache/blob/v1/README.md) for previous versions
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Pre-requisites
|
### Pre-requisites
|
||||||
@ -67,8 +37,7 @@ Create a workflow `.yml` file in your repositories `.github/workflows` directory
|
|||||||
|
|
||||||
### Inputs
|
### Inputs
|
||||||
|
|
||||||
* `path` - Directories to store and save the cache. Supports pattern matching, multipath and single file cache
|
* `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/master/packages/glob) for supported patterns.
|
||||||
> See [`@actions/glob`](https://github.com/actions/toolkit/tree/master/packages/glob) for supported patterns.
|
|
||||||
* `key` - An explicit key for restoring and saving the cache
|
* `key` - An explicit key for restoring and saving the cache
|
||||||
* `restore-keys` - An ordered list of keys to use for restoring the cache if no cache hit occurred for key
|
* `restore-keys` - An ordered list of keys to use for restoring the cache if no cache hit occurred for key
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ description: 'Cache artifacts like dependencies and build outputs to improve wor
|
|||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
path:
|
path:
|
||||||
description: 'A directory to store and save the cache'
|
description: 'A list of files, directories, and wildcard patterns to cache and restore'
|
||||||
required: true
|
required: true
|
||||||
key:
|
key:
|
||||||
description: 'An explicit key for restoring and saving the cache'
|
description: 'An explicit key for restoring and saving the cache'
|
||||||
|
29
examples.md
29
examples.md
@ -44,7 +44,19 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa
|
|||||||
```
|
```
|
||||||
|
|
||||||
Depending on the environment, huge packages might be pre-installed in the global cache folder.
|
Depending on the environment, huge packages might be pre-installed in the global cache folder.
|
||||||
If you do not want to include them, consider to move the cache folder like below.
|
With `actions/cache@v2` you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/master/packages/glob#exclude-patterns)
|
||||||
|
```yaml
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.nuget/packages
|
||||||
|
!~/.nuget/packages/unwanted
|
||||||
|
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-nuget-
|
||||||
|
```
|
||||||
|
|
||||||
|
Or you could move the cache folder like below.
|
||||||
>Note: This workflow does not work for projects that require files to be placed in user profile package folder
|
>Note: This workflow does not work for projects that require files to be placed in user profile package folder
|
||||||
```yaml
|
```yaml
|
||||||
env:
|
env:
|
||||||
@ -58,18 +70,6 @@ steps:
|
|||||||
${{ runner.os }}-nuget-
|
${{ runner.os }}-nuget-
|
||||||
```
|
```
|
||||||
|
|
||||||
With `actions/cache@v2` you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/master/packages/glob#exclude-patterns)
|
|
||||||
```yaml
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.nuget/packages
|
|
||||||
!~/.nuget/packages/unwanted
|
|
||||||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-nuget-
|
|
||||||
```
|
|
||||||
|
|
||||||
## D - DUB
|
## D - DUB
|
||||||
|
|
||||||
### POSIX
|
### POSIX
|
||||||
@ -426,8 +426,7 @@ When dependencies are installed later in the workflow, we must specify the same
|
|||||||
## Rust - Cargo
|
## Rust - Cargo
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Cache cargo
|
- uses: actions/cache@v2
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry
|
~/.cargo/registry
|
||||||
|
Loading…
Reference in New Issue
Block a user