From 1670e27193053b61a7738730c17988eafb3ee4cf Mon Sep 17 00:00:00 2001 From: h0x0er Date: Mon, 26 Sep 2022 22:22:19 +0530 Subject: [PATCH] added event validation function --- src/cache.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cache.ts b/src/cache.ts index 35a31c1..c1d2552 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -114,3 +114,8 @@ export enum CompressionMethod { ZstdWithoutLong = "zstd-without-long", Zstd = "zstd", } +// Refer: https://github.com/actions/cache/blob/12681847c623a9274356751fdf0a63576ff3f846/src/utils/actionUtils.ts#L53 +const RefKey = "GITHUB_REF"; +export function isValidEvent(): boolean { + return RefKey in process.env && Boolean(process.env[RefKey]); +} \ No newline at end of file