11// Script to notify the team when a P0 issue is created.
22
3+ const CRITICAL_LABEL = 'priority: critical' ;
34const marker = '<!-- P0 Issue Notification -->' ;
45
5- async function notifyTeam ( github , owner , repo , issue , marker ) {
6- const comment = `${ marker } :rotating_light: Attention Team :rotating_light:
6+ async function notifyTeam ( github , owner , repo , issue , marker ) {
7+ const safeTitle = String ( issue . title || '(no title)' )
8+ . replace ( / [ \r \n ] + / g, ' ' )
9+ . replace ( / @ / g, '@\u200b' )
10+ . trim ( ) ;
11+
12+ const comment = `${ marker } :rotating_light: Attention Team :rotating_light:
713@hiero-ledger/hiero-sdk-python-maintainers @hiero-ledger/hiero-sdk-python-committers @hiero-ledger/hiero-sdk-python-triage
814
9- A new P0 issue has been created: #${ issue . number } - ${ issue . title || '(no title)' }
15+ A new critical priority issue has been created: #${ issue . number } - ${ safeTitle }
1016Please prioritize this issue accordingly.
1117
1218Best Regards,
1319Automated Notification System` ;
1420
15- try {
16- await github . rest . issues . createComment ( {
17- owner,
18- repo,
19- issue_number : issue . number ,
20- body : comment ,
21- } ) ;
22- console . log ( `Notified team about P0 issue #${ issue . number } ` ) ;
23- return true ;
24- } catch ( commentErr ) {
25- console . log ( `Failed to notify team about P0 issue #${ issue . number } :` , commentErr . message || commentErr ) ;
26- return false ;
27- }
21+ try {
22+ await github . rest . issues . createComment ( {
23+ owner,
24+ repo,
25+ issue_number : issue . number ,
26+ body : comment ,
27+ } ) ;
28+ console . log ( `Notified team about ${ CRITICAL_LABEL } issue #${ issue . number } ` ) ;
29+ return true ;
30+ } catch ( commentErr ) {
31+ console . log ( `Failed to notify team about ${ CRITICAL_LABEL } issue #${ issue . number } :` , commentErr . message || commentErr ) ;
32+ return false ;
2833 }
34+ }
2935
3036module . exports = async ( { github, context } ) => {
3137 try {
@@ -34,8 +40,8 @@ module.exports = async ({ github, context }) => {
3440
3541 // Validations
3642 if ( ! issue ?. number ) return console . log ( 'No issue in payload' ) ;
37- if ( label ?. name ?. toLowerCase ( ) !== 'p0' ) return ;
38- if ( ! issue . labels ?. some ( l => l ?. name ?. toLowerCase ( ) === 'p0' ) ) return ;
43+ if ( label ?. name ?. toLowerCase ( ) !== CRITICAL_LABEL . toLowerCase ( ) ) return ;
44+ if ( ! issue . labels ?. some ( ( l ) => l ?. name ?. toLowerCase ( ) === CRITICAL_LABEL . toLowerCase ( ) ) ) return ;
3945
4046 // Check for existing comment
4147 const comments = await github . paginate ( github . rest . issues . listComments , {
@@ -44,7 +50,7 @@ module.exports = async ({ github, context }) => {
4450 if ( comments . some ( c => c . body ?. includes ( marker ) ) ) {
4551 return console . log ( `Notification already exists for #${ issue . number } ` ) ;
4652 }
47- // Post notification
53+ // Post notification
4854 await notifyTeam ( github , owner , repo , issue , marker ) ;
4955
5056 console . log ( '=== Summary ===' ) ;
0 commit comments