1
0
Fork 0
mirror of https://github.com/actions/cache.git synced 2025-07-16 21:27:54 +00:00

Fix: Remove event validation

This commit is contained in:
Andreas Möller 2020-05-17 10:25:49 +02:00
parent 16a133d9a7
commit 9572935725
No known key found for this signature in database
GPG key ID: 9FB20A0BAF60E11F
9 changed files with 3 additions and 116 deletions

View file

@ -33,5 +33,3 @@ 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";

View file

@ -8,16 +8,6 @@ import * as utils from "./utils/actionUtils";
async function run(): Promise<void> {
try {
// Validate inputs, this can cause task failure
if (!utils.isValidEvent()) {
utils.logWarning(
`Event Validation Error: The event type ${
process.env[Events.Key]
} is not supported because it's not tied to a branch or tag ref.`
);
return;
}
const primaryKey = core.getInput(Inputs.Key, { required: true });
core.saveState(State.CacheKey, primaryKey);

View file

@ -8,15 +8,6 @@ import * as utils from "./utils/actionUtils";
async function run(): Promise<void> {
try {
if (!utils.isValidEvent()) {
utils.logWarning(
`Event Validation Error: The event type ${
process.env[Events.Key]
} is not supported because it's not tied to a branch or tag ref.`
);
return;
}
const state = utils.getCacheState();
// Inputs are re-evaluted before the post action, so we want the original key used for restore

View file

@ -11,7 +11,6 @@ import {
CacheFilename,
CompressionMethod,
Outputs,
RefKey,
State
} from "../constants";
import { ArtifactCacheEntry } from "../contracts";
@ -108,12 +107,6 @@ export async function resolvePaths(patterns: string[]): Promise<string[]> {
return paths;
}
// 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 {
return RefKey in process.env && Boolean(process.env[RefKey]);
}
export function unlinkFile(path: fs.PathLike): Promise<void> {
return util.promisify(fs.unlink)(path);
}