Skip to content

Commit 3a03504

Browse files
committed
deploy(linkcheck): deal with stray "secondary rate limits"
Apparently it is relatively common to run into secondary rate limits when calling the `search` REST API in GitHub Actions. Let's try to just fall back to the regular `issues.listForRepo()` REST API, with manual filtering, after sleeping for a while. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 9a9dc94 commit 3a03504

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

.github/actions/deploy-to-github-pages/action.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,26 @@ runs:
112112
return s.replace(/^([^]{0,65000}\n)[^]*\n(.+)\n?$/, '$1\n[...]\n\n$2')
113113
})(await fs.promises.readFile('lychee.md', 'utf8'))
114114
115-
const req = { owner: context.repo.owner, repo: context.repo.repo }
116-
const q = `"Link+Checker+Report"+in:title+is:issue+label:linkchecker+is:open+repo:${req.owner}/${req.repo}`
117-
const issues = await github.rest.search.issuesAndPullRequests({ ...req, q, sort: 'created', per_page: 1 })
115+
const issues = await (async () => {
116+
const req = { owner: context.repo.owner, repo: context.repo.repo }
117+
const q = `"Link+Checker+Report"+in:title+is:issue+label:linkchecker+is:open+repo:${req.owner}/${req.repo}`
118+
try {
119+
return await github.rest.search.issuesAndPullRequests({ ...req, q, sort: 'created', per_page: 1 })
120+
} catch (e) {
121+
console.log(`Warning: ${e}; sleeping for 30 seconds and falling back to calling listForRepo()`)
122+
await new Promise(r => setTimeout(r, 30000))
123+
124+
const issues = await github.rest.issues.listForRepo({...req, state: 'open', per_page: 100})
125+
return {
126+
data: {
127+
items: issues.data.filter(
128+
e => e.title === 'Link Checker Report'
129+
&& e.labels.filter(l => l.name === 'linkchecker').length > 0
130+
)
131+
}
132+
}
133+
}
134+
})()
118135
119136
if (issues.data.items.length === 0) {
120137
if (process.env.lychee_exit_code !== '0') {

0 commit comments

Comments
 (0)