Deprecate save-always input (#1452)

The `save-always` input added in v4 is not
working as intended due to
`post-if` expressions not supporting the input
context.
To avoid breaking users who have already added
this input to their workflows, it is being
deprecated now and will be removed
in the next major version (v5).
See https://github.com/actions/cache/issues/1315 for more details.
This commit is contained in:
Josh Gross 2024-10-03 14:37:55 -04:00 committed by GitHub
parent f8a7ab490b
commit c74ca4022c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 34 deletions

View file

@ -243,24 +243,7 @@ with:
### Saving cache even if the build fails
There can be cases where a cache should be saved even if the build job fails. For example, a job can fail due to flaky tests but the caches can still be re-used. You can use `actions/cache/save` action to save the cache by using `if: always()` condition.
Similarly, `actions/cache/save` action can be conditionally used based on the output of the previous steps. This way you get more control on when to save the cache.
```yaml
steps:
- uses: actions/checkout@v4
.
. // restore if need be
.
- name: Build
run: /build.sh
- uses: actions/cache/save@v4
if: always() // or any other condition to invoke the save action
with:
path: path/to/dependencies
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
```
See [Always save cache](./save/README.md#always-save-cache).
### Saving cache once and reusing in multiple workflows