File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed
Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change 11async function main ( ) {
2- const fetchOpts = { headers : { } } ;
2+ const headers = {
3+ 'Accept' : 'application/vnd.github+json' ,
4+ 'X-GitHub-Api-Version' : '2022-11-28' ,
5+ 'User-Agent' : 'aztec-starter-ci'
6+ } ;
37 if ( process . env . GITHUB_TOKEN ) {
4- fetchOpts . headers . Authorization = `token ${ process . env . GITHUB_TOKEN } ` ;
8+ headers . Authorization = `Bearer ${ process . env . GITHUB_TOKEN } ` ;
59 }
610
7- const res = await fetch ( 'https://api.github.com/repos/AztecProtocol/aztec-packages/releases' , fetchOpts ) ;
8- const data = await res . json ( ) ;
11+ const url = 'https://api.github.com/repos/AztecProtocol/aztec-packages/releases?per_page=100' ;
12+ const res = await fetch ( url , { headers } ) ;
13+
14+ if ( ! res . ok ) {
15+ const body = await res . text ( ) . catch ( ( ) => '' ) ;
16+ console . error ( `GitHub API error ${ res . status } ${ res . statusText } : ${ body } ` ) ;
17+ process . exit ( 1 ) ;
18+ }
19+
20+ let data ;
21+ try {
22+ data = await res . json ( ) ;
23+ } catch ( err ) {
24+ console . error ( 'Failed to parse GitHub API response as JSON' , err ) ;
25+ process . exit ( 1 ) ;
26+ }
27+
28+ if ( ! Array . isArray ( data ) ) {
29+ console . error ( `Unexpected GitHub API response (expected array): ${ JSON . stringify ( data , null , 2 ) } ` ) ;
30+ process . exit ( 1 ) ;
31+ }
932
1033 const release = data . find ( r => ! r . draft && ! / n i g h t l y / i. test ( r . tag_name ) && ! / s t a g i n g / i. test ( r . tag_name ) ) ;
1134 if ( ! release ) {
You can’t perform that action at this time.
0 commit comments