Skip to content

Commit

Permalink
Try another approach
Browse files Browse the repository at this point in the history
  • Loading branch information
JunTaoLuo committed Dec 14, 2023
1 parent 5d6efa3 commit 2066c65
Showing 1 changed file with 31 additions and 33 deletions.
64 changes: 31 additions & 33 deletions .github/workflows/tugboat-refresh-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2066c65

Please sign in to comment.