mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-22 11:25:31 +00:00
Allow all events to access cache
This commit is contained in:
parent
5d8c995f20
commit
ccc66f769e
9 changed files with 40 additions and 63 deletions
|
@ -33,3 +33,5 @@ export enum CompressionMethod {
|
|||
// over the socket during this period, the socket is destroyed and the download
|
||||
// is aborted.
|
||||
export const SocketTimeout = 5000;
|
||||
|
||||
export const RefKey = "GITHUB_REF";
|
||||
|
|
|
@ -13,9 +13,7 @@ async function run(): Promise<void> {
|
|||
utils.logWarning(
|
||||
`Event Validation Error: The event type ${
|
||||
process.env[Events.Key]
|
||||
} is not supported. Only ${utils
|
||||
.getSupportedEvents()
|
||||
.join(", ")} events are supported at this time.`
|
||||
} is not supported because it's not tied to a branch or tag ref.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -12,9 +12,7 @@ async function run(): Promise<void> {
|
|||
utils.logWarning(
|
||||
`Event Validation Error: The event type ${
|
||||
process.env[Events.Key]
|
||||
} is not supported. Only ${utils
|
||||
.getSupportedEvents()
|
||||
.join(", ")} events are supported at this time.`
|
||||
} is not supported because it's not tied to a branch or tag ref.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -7,13 +7,17 @@ import * as path from "path";
|
|||
import * as util from "util";
|
||||
import * as uuidV4 from "uuid/v4";
|
||||
|
||||
<<<<<<< HEAD
|
||||
import {
|
||||
CacheFilename,
|
||||
CompressionMethod,
|
||||
Events,
|
||||
Outputs,
|
||||
RefKey,
|
||||
State
|
||||
} from "../constants";
|
||||
=======
|
||||
import { Outputs, RefKey, State } from "../constants";
|
||||
>>>>>>> Allow all events to access cache
|
||||
import { ArtifactCacheEntry } from "../contracts";
|
||||
|
||||
// From https://github.com/actions/toolkit/blob/master/packages/tool-cache/src/tool-cache.ts#L23
|
||||
|
@ -108,16 +112,10 @@ export async function resolvePaths(patterns: string[]): Promise<string[]> {
|
|||
return paths;
|
||||
}
|
||||
|
||||
export function getSupportedEvents(): string[] {
|
||||
return [Events.Push, Events.PullRequest];
|
||||
}
|
||||
|
||||
// Currently the cache token is only authorized for push and pull_request events
|
||||
// All other events will fail when reading and saving the cache
|
||||
// Cache token authorized for all events that are tied to a ref
|
||||
// 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 {
|
||||
const githubEvent = process.env[Events.Key] || "";
|
||||
return getSupportedEvents().includes(githubEvent);
|
||||
return RefKey in process.env;
|
||||
}
|
||||
|
||||
export function unlinkFile(path: fs.PathLike): Promise<void> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue