1
0
mirror of synced 2025-12-22 11:26:57 -05:00

fix(link-check): add WAF token to avoid 403 (#26964)

This commit is contained in:
Mike Surowiec
2022-04-15 16:29:23 -05:00
committed by GitHub
parent dabaee7f07
commit 8bb525188f
2 changed files with 20 additions and 9 deletions

View File

@@ -14,6 +14,8 @@ if (!process.env.GITHUB_TOKEN) {
process.exit(1)
}
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
main()
async function main() {
@@ -91,16 +93,23 @@ async function main() {
}
}
}
const brokenLinks = []
await Promise.all(
docsLinksFiles.map(async (file) => {
try {
await got(file[0])
} catch {
brokenLinks.push(file)
}
})
)
// Done serially with delay to avoid hitting the rate limiter
for (const file of docsLinksFiles) {
try {
await got(file[0], {
headers: {
'X-WAF-TOKEN': process.env.WAF_TOKEN,
},
})
} catch (e) {
brokenLinks.push(file)
} finally {
await sleep(300)
}
}
if (!brokenLinks.length) {
console.log('All links are good!')
process.exit(0)