diff --git a/.github/workflows/tugboat-refresh-cache.yml b/.github/workflows/tugboat-refresh-cache.yml index 6dd20c139..3d2df4bf5 100644 --- a/.github/workflows/tugboat-refresh-cache.yml +++ b/.github/workflows/tugboat-refresh-cache.yml @@ -17,49 +17,47 @@ jobs: console.log(`owner: ${context.repo.owner}`) console.log(`repo: ${context.repo.repo}`) - const prs = [] - for await (const response of octokit.paginate.iterator( + const openPrOpts = github.rest.pulls.list.endpoint.merge() + const prs = await github.paginate( github.rest.pulls.list, { owner: context.repo.owner, repo: context.repo.repo, state: 'open', - } - )) { - response.data.map( - (pr) => { - console.log(`PR: ${pr}`) - prs.push(pr.number) - } - ) + }, + (response) => response.data.map((pr) => pr.number) + ) + + for (const pr of prs) { + console.log(`PR: ${pr}`) } - # const cacheOps = github.rest.actions.getActionsCacheList.endpoint.merge({ - # owner: context.repo.owner, - # repo: context.repo.repo, - # }) - # const cacheKeys = await github.paginate( - # cacheOps, - # (response) => response.data.map( - # (cache) => cache.key - # ) - # ) + const cacheOps = github.rest.actions.getActionsCacheList.endpoint.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + }) + const cacheKeys = await github.paginate( + cacheOps, + (response) => response.data.map( + (cache) => cache.key + ) + ) - # for (const key of cacheKeys) { - # console.log(`Key: ${key}`) - # } + for (const key of cacheKeys) { + console.log(`Key: ${key}`) + } - # const toRefresh = [] - # for (const pr of prs) { - # if (cacheKeys.includes(`${{ runner.os }}-tugboat-preview-id-pr-${pr}`)) { - # console.log(`Need to refresh: ${pr}`) - # toRefresh.push(pr) - # } - # } + const toRefresh = [] + for (const pr of prs) { + if (cacheKeys.includes(`${{ runner.os }}-tugboat-preview-id-pr-${pr}`)) { + console.log(`Need to refresh: ${pr}`) + toRefresh.push(pr) + } + } - # const result = JSON.stringify(toRefresh) - # console.log(`Result: ${result}`) - # return result + const result = JSON.stringify(toRefresh) + console.log(`Result: ${result}`) + return result result-encoding: string # Refresh cache for given keys