mirror of
https://github.com/actions/cache.git
synced 2024-11-21 17:31:27 +01:00
React to feedback
This commit is contained in:
parent
581312be20
commit
e6c708b5ce
3 changed files with 24 additions and 56 deletions
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).
|
||||
|
||||
## 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
|
||||
- name: Cache multiple relative paths
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
node_modules
|
||||
dist
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
```
|
||||
```yaml
|
||||
- name: Cache multiple absolute paths
|
||||
- name: Cache multiple paths
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/cache
|
||||
/path/to/dependencies
|
||||
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
|
||||
!~/cache/exclude
|
||||
**/node_modules
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
```
|
||||
|
||||
and single file caches.
|
||||
|
||||
```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`
|
||||
* 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`
|
||||
* 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
|
||||
|
||||
Refer [here](https://github.com/actions/cache/blob/v1/README.md) for previous versions
|
||||
|
||||
## Usage
|
||||
|
||||
### Pre-requisites
|
||||
|
@ -67,8 +37,7 @@ Create a workflow `.yml` file in your repositories `.github/workflows` directory
|
|||
|
||||
### Inputs
|
||||
|
||||
* `path` - Directories to store and save the cache. Supports pattern matching, multipath and single file cache
|
||||
> See [`@actions/glob`](https://github.com/actions/toolkit/tree/master/packages/glob) for supported patterns.
|
||||
* `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.
|
||||
* `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
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ description: 'Cache artifacts like dependencies and build outputs to improve wor
|
|||
author: 'GitHub'
|
||||
inputs:
|
||||
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
|
||||
key:
|
||||
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.
|
||||
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
|
||||
```yaml
|
||||
env:
|
||||
|
@ -58,18 +70,6 @@ steps:
|
|||
${{ 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
|
||||
|
||||
### POSIX
|
||||
|
@ -426,8 +426,7 @@ When dependencies are installed later in the workflow, we must specify the same
|
|||
## Rust - Cargo
|
||||
|
||||
```yaml
|
||||
- name: Cache cargo
|
||||
uses: actions/cache@v2
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
|
|
Loading…
Reference in a new issue