mirror of
https://github.com/actions/cache.git
synced 2025-04-21 19:46:46 +00:00
Validate event type during restore
This commit is contained in:
parent
4b0709a0d5
commit
bae12fc444
4 changed files with 119 additions and 2 deletions
|
@ -5,7 +5,7 @@ import * as os from "os";
|
|||
import * as path from "path";
|
||||
import * as uuidV4 from "uuid/v4";
|
||||
|
||||
import { Outputs, State } from "../constants";
|
||||
import { Events, Outputs, State } from "../constants";
|
||||
import { ArtifactCacheEntry } from "../contracts";
|
||||
|
||||
// From https://github.com/actions/toolkit/blob/master/packages/tool-cache/src/tool-cache.ts#L23
|
||||
|
@ -84,3 +84,11 @@ export function resolvePath(filePath: string): string {
|
|||
|
||||
return path.resolve(filePath);
|
||||
}
|
||||
|
||||
// Currently the cache token is only authorized for push and pull_request events
|
||||
// All other events will fail when reading and saving the cache
|
||||
// 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 githubEvent === Events.Push || githubEvent === Events.PullRequest;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue