@@ -11,28 +11,23 @@ const formatBody = (input) => {
11
11
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;
12
12
const markdownLinkRe = / \[ ( [ ^ \] ] + ) \] \( ( [ ^ \) ] + ) \) / g;
13
13
const creditRe = new RegExp ( `Submitted by (?:undefined|${ markdownLinkRe . source } )` , 'ig' ) ;
14
- const repeatedNewlineRe = / ( \n [ ] * ) + / g;
14
+ const repeatedNewlineRe = / (?: \n [ ] * ) * ( \n [ ] * ) / g;
15
15
return input
16
16
. replace ( titleRe , '' )
17
17
. replace ( updatedDepsRe , '' )
18
18
. replace ( creditRe , ( _match , text , url ) => {
19
19
if ( ! text || / @ k i t t e n | @ J o v i D e C r o o c k / i. test ( text ) ) return '' ;
20
20
return `Submitted by [${ text } ](${ url } )` ;
21
21
} )
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' )
26
24
. trim ( ) ;
27
25
} ;
28
26
29
27
async function getReleaseBody ( name , version ) {
30
28
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 } ) ;
36
31
37
32
const release = result . status === 200 ? result . data : undefined ;
38
33
if ( ! release || ! release . body ) return ;
@@ -66,7 +61,7 @@ async function main() {
66
61
. join ( '\n\n' ) ;
67
62
68
63
// Send message through a discord webhook or bot
69
- const response = fetch ( WEBHOOK_URL , {
64
+ const response = await fetch ( WEBHOOK_URL , {
70
65
method : 'POST' ,
71
66
headers : {
72
67
'Content-Type' : 'application/json' ,
@@ -75,11 +70,9 @@ async function main() {
75
70
} ) ;
76
71
77
72
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 ( ) ) ;
80
75
}
81
-
82
- return response ;
83
76
}
84
77
85
78
main ( ) . then ( ) . catch ( console . error ) ;
0 commit comments