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 51
51
run : npm ci
52
52
53
53
- name : Run broken github/github link check
54
+ env :
55
+ WAF_TOKEN : ${{ secrets.WAF_TOKEN }}
54
56
run : |
55
57
script/check-github-github-links.js > broken_github_github_links.md
56
58
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ if (!process.env.GITHUB_TOKEN) {
14
14
process . exit ( 1 )
15
15
}
16
16
17
+ const sleep = ( ms ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) )
18
+
17
19
main ( )
18
20
19
21
async function main ( ) {
@@ -91,16 +93,23 @@ async function main() {
91
93
}
92
94
}
93
95
}
96
+
94
97
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
+
104
113
if ( ! brokenLinks . length ) {
105
114
console . log ( 'All links are good!' )
106
115
process . exit ( 0 )
You can’t perform that action at this time.
0 commit comments