mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 13:29:10 +08:00 
			
		
		
		
	Merge pull request #263 from actions/users/aiyan/allow-all-events
Allow all events to access cache
This commit is contained in:
		@@ -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;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -10,8 +10,8 @@ import * as uuidV4 from "uuid/v4";
 | 
			
		||||
import {
 | 
			
		||||
    CacheFilename,
 | 
			
		||||
    CompressionMethod,
 | 
			
		||||
    Events,
 | 
			
		||||
    Outputs,
 | 
			
		||||
    RefKey,
 | 
			
		||||
    State
 | 
			
		||||
} from "../constants";
 | 
			
		||||
import { ArtifactCacheEntry } from "../contracts";
 | 
			
		||||
@@ -108,16 +108,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 && Boolean(process.env[RefKey]);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function unlinkFile(path: fs.PathLike): Promise<void> {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user