1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-05-01 15:59:54 +02:00

Enhancement: Allow usage when GITHUB_REF or ACTIONS_CACHE_REF are defined

This commit is contained in:
Andreas Möller 2020-05-16 23:05:56 +02:00
parent 16a133d9a7
commit 77fd223211
No known key found for this signature in database
GPG key ID: 9FB20A0BAF60E11F
7 changed files with 792 additions and 638 deletions

View file

@ -11,7 +11,7 @@ import {
CacheFilename,
CompressionMethod,
Outputs,
RefKey,
RefKeys,
State
} from "../constants";
import { ArtifactCacheEntry } from "../contracts";
@ -108,10 +108,18 @@ export async function resolvePaths(patterns: string[]): Promise<string[]> {
return paths;
}
// Cache token authorized for all events that are tied to a ref
// Cache token authorized for events where a reference is defined
// See GitHub Context https://help.github.com/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#github-context
export function isValidEvent(): boolean {
return RefKey in process.env && Boolean(process.env[RefKey]);
for (let i = 0; i < RefKeys.length; i++) {
let refKey = RefKeys[i];
if (refKey in process.env) {
return Boolean(process.env[refKey])
}
}
return false;
}
export function unlinkFile(path: fs.PathLike): Promise<void> {