1
0
Fork 0

changes restore refs to be set

pull/1935/head
Prajjwal 2024-06-20 12:15:48 +05:30
parent cb3493c613
commit 84b7e683e3
2 changed files with 10 additions and 10 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "github-actions.warp-cache", "name": "github-actions.warp-cache",
"version": "1.2.1", "version": "1.2.2",
"preview": true, "preview": true,
"description": "Github action to use WarpBuild's in-house cache offering", "description": "Github action to use WarpBuild's in-house cache offering",
"keywords": [ "keywords": [

View File

@ -149,23 +149,23 @@ export async function getCacheEntry(
options?.enableCrossArchArchive options?.enableCrossArchArchive
) )
const restoreBranches: Array<string> = [] const restoreBranches: Set<string> = new Set()
const restoreRepos: Array<string> = [] const restoreRepos: Set<string> = new Set()
switch (github.context.eventName) { switch (github.context.eventName) {
case 'pull_request': case 'pull_request':
{ {
const pullPayload = github.context.payload as PullRequestEvent const pullPayload = github.context.payload as PullRequestEvent
// Adds PR head branch and base branch to restoreBranches // Adds PR head branch and base branch to restoreBranches
restoreBranches.push( restoreBranches.add(
`refs/heads/${pullPayload?.pull_request?.head?.ref}` `refs/heads/${pullPayload?.pull_request?.head?.ref}`
) )
restoreBranches.push( restoreBranches.add(
`refs/heads/${pullPayload?.pull_request?.base?.ref}` `refs/heads/${pullPayload?.pull_request?.base?.ref}`
) )
// Adds default branch to restoreBranches // Adds default branch to restoreBranches
restoreBranches.push( restoreBranches.add(
`refs/heads/${pullPayload?.repository?.default_branch}` `refs/heads/${pullPayload?.repository?.default_branch}`
) )
@ -174,7 +174,7 @@ export async function getCacheEntry(
pullPayload?.pull_request?.head?.repo?.name !== pullPayload?.pull_request?.head?.repo?.name !==
pullPayload?.repository?.name pullPayload?.repository?.name
) { ) {
restoreRepos.push(pullPayload?.pull_request?.head?.repo?.name) restoreRepos.add(pullPayload?.pull_request?.head?.repo?.name)
} }
} }
break break
@ -184,7 +184,7 @@ export async function getCacheEntry(
const pushPayload = github.context.payload as PushEvent const pushPayload = github.context.payload as PushEvent
// Default branch is not in the complete format // Default branch is not in the complete format
// Ref: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push // Ref: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#push
restoreBranches.push( restoreBranches.add(
`refs/heads/${pushPayload?.repository?.default_branch}` `refs/heads/${pushPayload?.repository?.default_branch}`
) )
} }
@ -200,8 +200,8 @@ export async function getCacheEntry(
vcs_repository: getVCSRepository(), vcs_repository: getVCSRepository(),
vcs_ref: getVCSRef(), vcs_ref: getVCSRef(),
annotations: getAnnotations(), annotations: getAnnotations(),
restore_branches: restoreBranches, restore_branches: Array.from(restoreBranches),
restore_repos: restoreRepos restore_repos: Array.from(restoreRepos)
} }
const response = await retryTypedResponse('getCacheEntry', async () => const response = await retryTypedResponse('getCacheEntry', async () =>