@@ -11,28 +11,23 @@ const formatBody = (input) => {
1111 const updatedDepsRe = / \n - \s * U p d a t e d d e p e n d e n c i e s [ \s \S ] + \n ( \n \s + - [ \s \S ] + ) * / gi;
1212 const markdownLinkRe = / \[ ( [ ^ \] ] + ) \] \( ( [ ^ \) ] + ) \) / g;
1313 const creditRe = new RegExp ( `Submitted by (?:undefined|${ markdownLinkRe . source } )` , 'ig' ) ;
14- const repeatedNewlineRe = / ( \n [ ] * ) + / g;
14+ const repeatedNewlineRe = / (?: \n [ ] * ) * ( \n [ ] * ) / g;
1515 return input
1616 . replace ( titleRe , '' )
1717 . replace ( updatedDepsRe , '' )
1818 . replace ( creditRe , ( _match , text , url ) => {
1919 if ( ! text || / @ k i t t e n | @ J o v i D e C r o o c k / i. test ( text ) ) return '' ;
2020 return `Submitted by [${ text } ](${ url } )` ;
2121 } )
22- . replace ( markdownLinkRe , ( _match , text , url ) => {
23- return `[${ text } ](<${ url } >)` ;
24- } )
25- . replace ( repeatedNewlineRe , '\n' )
22+ . replace ( markdownLinkRe , ( _match , text , url ) => `[${ text } ](<${ url } >)` )
23+ . replace ( repeatedNewlineRe , ( _match , text ) => text ? ` ${ text } ` : '\n' )
2624 . trim ( ) ;
2725} ;
2826
2927async function getReleaseBody ( name , version ) {
3028 const tag = `${ name } @${ version } ` ;
31- const result = await octokit . rest . repos . getReleaseByTag ( {
32- owner : 'urql-graphql' ,
33- repo : 'urql' ,
34- tag,
35- } ) ;
29+ const [ owner , repo ] = process . env . GITHUB_REPOSITORY . split ( '/' ) ;
30+ const result = await octokit . rest . repos . getReleaseByTag ( { owner, repo, tag } ) ;
3631
3732 const release = result . status === 200 ? result . data : undefined ;
3833 if ( ! release || ! release . body ) return ;
@@ -66,7 +61,7 @@ async function main() {
6661 . join ( '\n\n' ) ;
6762
6863 // Send message through a discord webhook or bot
69- const response = fetch ( WEBHOOK_URL , {
64+ const response = await fetch ( WEBHOOK_URL , {
7065 method : 'POST' ,
7166 headers : {
7267 'Content-Type' : 'application/json' ,
@@ -75,11 +70,9 @@ async function main() {
7570 } ) ;
7671
7772 if ( ! response . ok ) {
78- console . log ( 'Something went wrong while sending the discord webhook.' ) ;
79- return ;
73+ console . error ( 'Something went wrong while sending the discord webhook.' , response . status ) ;
74+ console . error ( await response . text ( ) ) ;
8075 }
81-
82- return response ;
8376}
8477
8578main ( ) . then ( ) . catch ( console . error ) ;
0 commit comments