Skip to content

Commit

Permalink
Trying another approach to pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
JunTaoLuo committed Dec 14, 2023
1 parent 5985e8b commit 5d6efa3
Showing 1 changed file with 37 additions and 38 deletions.
75 changes: 37 additions & 38 deletions .github/workflows/tugboat-refresh-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,49 @@ jobs:
console.log(`owner: ${context.repo.owner}`)
console.log(`repo: ${context.repo.repo}`)
const openPrOpts = github.rest.pulls.list.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
})
const prs = await github.paginate(
openPrOpts,
(response) => {
response.data.map(
(pr) => pr.number
)
const prs = []
for await (const response of octokit.paginate.iterator(
github.rest.pulls.list,
{
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
}
)
for (const pr of prs) {
console.log(`PR: ${pr}`)
)) {
response.data.map(
(pr) => {
console.log(`PR: ${pr}`)
prs.push(pr.number)
}
)
}
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
Expand Down

0 comments on commit 5d6efa3

Please sign in to comment.