From 5b3af52a51cd5f9f257cb5ce00fff8fad92fed1b Mon Sep 17 00:00:00 2001 From: Prajjwal Date: Thu, 21 Nov 2024 11:14:39 +0530 Subject: [PATCH] handles different types of events for branch restores --- packages/warp-cache/package.json | 2 +- .../warp-cache/src/internal/cacheHttpClient.ts | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/warp-cache/package.json b/packages/warp-cache/package.json index 510d82c3..092e0ccc 100644 --- a/packages/warp-cache/package.json +++ b/packages/warp-cache/package.json @@ -1,6 +1,6 @@ { "name": "github-actions.warp-cache", - "version": "1.4.0", + "version": "1.4.1", "preview": true, "description": "Github action to use WarpBuild's in-house cache offering", "keywords": [ diff --git a/packages/warp-cache/src/internal/cacheHttpClient.ts b/packages/warp-cache/src/internal/cacheHttpClient.ts index 736183ae..9bf44129 100644 --- a/packages/warp-cache/src/internal/cacheHttpClient.ts +++ b/packages/warp-cache/src/internal/cacheHttpClient.ts @@ -184,18 +184,13 @@ export async function getCacheEntry( } } break - case 'push': - case 'workflow_dispatch': - { - const pushPayload = github.context.payload as PushEvent - // Default branch is not in the complete format - // Ref: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push - restoreBranches.add( - `refs/heads/${pushPayload?.repository?.default_branch}` - ) - } - break default: + const payload = github?.context?.payload + // Default branch is not in the complete format + // Ref: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push + if (payload?.repository?.default_branch) { + restoreBranches.add(`refs/heads/${payload?.repository?.default_branch}`) + } break }