mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-23 17:23:59 +08:00
Removed input and state and added env
This commit is contained in:
parent
1cbab03e0e
commit
133764e0c3
6 changed files with 24 additions and 29 deletions
|
@ -3,8 +3,7 @@ export enum Inputs {
|
|||
Path = "path",
|
||||
RestoreKeys = "restore-keys",
|
||||
UploadChunkSize = "upload-chunk-size",
|
||||
StrictRestore = "strict-restore",
|
||||
SaveCacheOnAnyFailure = "saveCacheOnAnyFailure"
|
||||
StrictRestore = "strict-restore"
|
||||
}
|
||||
|
||||
export enum Outputs {
|
||||
|
@ -13,8 +12,7 @@ export enum Outputs {
|
|||
|
||||
export enum State {
|
||||
CachePrimaryKey = "CACHE_KEY",
|
||||
CacheMatchedKey = "CACHE_RESULT",
|
||||
SaveCache = "SAVE_CACHE"
|
||||
CacheMatchedKey = "CACHE_RESULT"
|
||||
}
|
||||
|
||||
export enum Events {
|
||||
|
@ -23,4 +21,7 @@ export enum Events {
|
|||
PullRequest = "pull_request"
|
||||
}
|
||||
|
||||
export enum Variables {
|
||||
SaveCacheOnAnyFailure = "SAVE_CACHE_ON_ANY_FAILURE"
|
||||
}
|
||||
export const RefKey = "GITHUB_REF";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as cache from "@actions/cache";
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import { Events, Inputs, State } from "./constants";
|
||||
import { Events, Inputs, State, Variables } from "./constants";
|
||||
import * as utils from "./utils/actionUtils";
|
||||
|
||||
async function run(): Promise<void> {
|
||||
|
@ -36,14 +36,12 @@ async function run(): Promise<void> {
|
|||
);
|
||||
|
||||
//Check if user wants to save cache despite of failure in any previous job
|
||||
const saveCache = core.getInput(Inputs.SaveCacheOnAnyFailure);
|
||||
const saveCache = process.env[Variables.SaveCacheOnAnyFailure];
|
||||
if (saveCache === "yes") {
|
||||
core.saveState(State.SaveCache, saveCache);
|
||||
// core.exportVariable(Variables.SaveCacheOnAnyFailure, saveCache);
|
||||
core.info(
|
||||
`Input saveCacheOnAnyFailure is set to yes, the cache will be saved despite of any failure in the build.`
|
||||
`Environment Variable ${Variables.SaveCacheOnAnyFailure} is set to yes, the cache will be saved despite of any failure in the build.`
|
||||
);
|
||||
core.info(core.getState(State.SaveCache));
|
||||
core.info(core.getState(State.CachePrimaryKey));
|
||||
}
|
||||
|
||||
if (!cacheKey) {
|
||||
|
|
|
@ -25,8 +25,7 @@ async function run(): Promise<void> {
|
|||
}
|
||||
|
||||
const state = utils.getCacheState();
|
||||
core.info(core.getState(State.SaveCache));
|
||||
core.info(core.getState(State.CachePrimaryKey));
|
||||
|
||||
// Inputs are re-evaluted before the post action, so we want the original key used for restore
|
||||
const primaryKey =
|
||||
core.getState(State.CachePrimaryKey) || core.getInput(Inputs.Key);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue