mirror of
https://github.com/actions/cache.git
synced 2025-04-21 22:08:41 +00:00
fix needs
option for test-only-restore
job
* also format code with prettier
This commit is contained in:
parent
f20d3c830c
commit
2807da784f
2 changed files with 8 additions and 8 deletions
2
.github/workflows/workflow.yml
vendored
2
.github/workflows/workflow.yml
vendored
|
@ -72,7 +72,7 @@ jobs:
|
|||
test-cache
|
||||
~/test-cache
|
||||
test-only-restore:
|
||||
needs: test-restore
|
||||
needs: test-save
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
|
|
14
src/save.ts
14
src/save.ts
|
@ -10,13 +10,13 @@ import * as utils from "./utils/actionUtils";
|
|||
process.on("uncaughtException", e => utils.logWarning(e.message));
|
||||
|
||||
async function run(): Promise<void> {
|
||||
const save = ! core.getBooleanInput(Inputs.OnlyRestore);
|
||||
const save = !core.getBooleanInput(Inputs.OnlyRestore);
|
||||
if (save) {
|
||||
try {
|
||||
if (!utils.isCacheFeatureAvailable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!utils.isValidEvent()) {
|
||||
utils.logWarning(
|
||||
`Event Validation Error: The event type ${
|
||||
|
@ -25,27 +25,27 @@ async function run(): Promise<void> {
|
|||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const state = utils.getCacheState();
|
||||
|
||||
|
||||
// Inputs are re-evaluted before the post action, so we want the original key used for restore
|
||||
const primaryKey = core.getState(State.CachePrimaryKey);
|
||||
if (!primaryKey) {
|
||||
utils.logWarning(`Error retrieving key from state.`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (utils.isExactKeyMatch(primaryKey, state)) {
|
||||
core.info(
|
||||
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const cachePaths = utils.getInputAsArray(Inputs.Path, {
|
||||
required: true
|
||||
});
|
||||
|
||||
|
||||
try {
|
||||
await cache.saveCache(cachePaths, primaryKey, {
|
||||
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
|
||||
|
|
Loading…
Add table
Reference in a new issue