File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed
Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change 5151 run : npm ci
5252
5353 - name : Run broken github/github link check
54+ env :
55+ WAF_TOKEN : ${{ secrets.WAF_TOKEN }}
5456 run : |
5557 script/check-github-github-links.js > broken_github_github_links.md
5658
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ if (!process.env.GITHUB_TOKEN) {
1414 process . exit ( 1 )
1515}
1616
17+ const sleep = ( ms ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) )
18+
1719main ( )
1820
1921async function main ( ) {
@@ -91,16 +93,23 @@ async function main() {
9193 }
9294 }
9395 }
96+
9497 const brokenLinks = [ ]
95- await Promise . all (
96- docsLinksFiles . map ( async ( file ) => {
97- try {
98- await got ( file [ 0 ] )
99- } catch {
100- brokenLinks . push ( file )
101- }
102- } )
103- )
98+ // Done serially with delay to avoid hitting the rate limiter
99+ for ( const file of docsLinksFiles ) {
100+ try {
101+ await got ( file [ 0 ] , {
102+ headers : {
103+ 'X-WAF-TOKEN' : process . env . WAF_TOKEN ,
104+ } ,
105+ } )
106+ } catch ( e ) {
107+ brokenLinks . push ( file )
108+ } finally {
109+ await sleep ( 300 )
110+ }
111+ }
112+
104113 if ( ! brokenLinks . length ) {
105114 console . log ( 'All links are good!' )
106115 process . exit ( 0 )
You can’t perform that action at this time.
0 commit comments