Validate event type during restore

This commit is contained in:
Josh Gross 2019-11-07 14:15:44 -05:00
parent 4b0709a0d5
commit bae12fc444
4 changed files with 119 additions and 2 deletions

View file

@ -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;
}