Skip to content

Commit

Permalink
feat: save cache on job failure
Browse files Browse the repository at this point in the history
  • Loading branch information
LNSD authored and TimJentzsch committed Feb 20, 2024
1 parent c4eff7b commit c7e8aa4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ jobs:
## Inputs
| Name | Description | Type | Default |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------- |
| `cache-group` | The group of the cache, defaults to the job ID. If you want two jobs to share the same cache, give them the same group name. | `string` | `${{ github.job }}` |
| `cargo-home` | The location of the Cargo cache files. If you specify the `CARGO_HOME` env variable for your commands, you need to set it here too. This must NOT end with the trailing slash of the directory. | `string` | `~/.cargo` |
| `cargo-target-dir` | Location of where to place all generated artifacts, relative to the current working directory. If you specify the `CARGO_TARGET_DIR` env variable for your commands, you need to set it here too. This must NOT end with the trailing slash of the directory. | `string` | `target` |
| Name | Description | Type | Default |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------------------- |
| `cache-group` | The group of the cache, defaults to the job ID. If you want two jobs to share the same cache, give them the same group name. | `string` | `${{ github.job }}` |
| `cargo-home` | The location of the Cargo cache files. If you specify the `CARGO_HOME` env variable for your commands, you need to set it here too. This must NOT end with the trailing slash of the directory. | `string` | `~/.cargo` |
| `cargo-target-dir` | Location of where to place all generated artifacts, relative to the current working directory. If you specify the `CARGO_TARGET_DIR` env variable for your commands, you need to set it here too. This must NOT end with the trailing slash of the directory. | `string` | `target` |
| `save-always` | Run the post step to save the cache even if another step before fails. | `boolean` | `true` |

## Outputs

Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ inputs:
Defaults to `target`.
required: false
default: target
save-always:
description: |
Run the post step to save the cache even if another step before fails.
Defaults to `true`.
required: false
default: true
outputs:
cache-hit:
description: |
Expand Down Expand Up @@ -81,6 +87,7 @@ runs:
id: cache
uses: actions/cache@v4
with:
save-always: ${{ inputs.save-always }}
path: |
${{ inputs.cargo-home }}/bin/
${{ inputs.cargo-home }}/registry/index/
Expand Down

0 comments on commit c7e8aa4

Please sign in to comment.