diff --git a/.github/scripts/bot-p0-issues-notify-team.js b/.github/scripts/bot-p0-issues-notify-team.js index 1793a716e..cdbd77e84 100644 --- a/.github/scripts/bot-p0-issues-notify-team.js +++ b/.github/scripts/bot-p0-issues-notify-team.js @@ -1,31 +1,37 @@ // Script to notify the team when a P0 issue is created. +const CRITICAL_LABEL = 'priority: critical'; const marker = ''; - async function notifyTeam(github, owner, repo, issue, marker) { - const comment = `${marker} :rotating_light: Attention Team :rotating_light: +async function notifyTeam(github, owner, repo, issue, marker) { + const safeTitle = String(issue.title || '(no title)') + .replace(/[\r\n]+/g, ' ') + .replace(/@/g, '@\u200b') + .trim(); + + const comment = `${marker} :rotating_light: Attention Team :rotating_light: @hiero-ledger/hiero-sdk-python-maintainers @hiero-ledger/hiero-sdk-python-committers @hiero-ledger/hiero-sdk-python-triage -A new P0 issue has been created: #${issue.number} - ${issue.title || '(no title)'} +A new critical priority issue has been created: #${issue.number} - ${safeTitle} Please prioritize this issue accordingly. Best Regards, Automated Notification System`; - try { - await github.rest.issues.createComment({ - owner, - repo, - issue_number: issue.number, - body: comment, - }); - console.log(`Notified team about P0 issue #${issue.number}`); - return true; - } catch (commentErr) { - console.log(`Failed to notify team about P0 issue #${issue.number}:`, commentErr.message || commentErr); - return false; - } + try { + await github.rest.issues.createComment({ + owner, + repo, + issue_number: issue.number, + body: comment, + }); + console.log(`Notified team about ${CRITICAL_LABEL} issue #${issue.number}`); + return true; + } catch (commentErr) { + console.log(`Failed to notify team about ${CRITICAL_LABEL} issue #${issue.number}:`, commentErr.message || commentErr); + return false; } +} module.exports = async ({ github, context }) => { try { @@ -34,8 +40,8 @@ module.exports = async ({ github, context }) => { // Validations if (!issue?.number) return console.log('No issue in payload'); - if (label?.name?.toLowerCase() !== 'p0') return; - if (!issue.labels?.some(l => l?.name?.toLowerCase() === 'p0')) return; + if (label?.name?.toLowerCase() !== CRITICAL_LABEL.toLowerCase()) return; + if (!issue.labels?.some((l) => l?.name?.toLowerCase() === CRITICAL_LABEL.toLowerCase())) return; // Check for existing comment const comments = await github.paginate(github.rest.issues.listComments, { @@ -44,7 +50,7 @@ module.exports = async ({ github, context }) => { if (comments.some(c => c.body?.includes(marker))) { return console.log(`Notification already exists for #${issue.number}`); } - // Post notification + // Post notification await notifyTeam(github, owner, repo, issue, marker); console.log('=== Summary ==='); diff --git a/.github/workflows/bot-p0-issues-notify-team.yml b/.github/workflows/bot-p0-issues-notify-team.yml index 451169145..f8f812afd 100644 --- a/.github/workflows/bot-p0-issues-notify-team.yml +++ b/.github/workflows/bot-p0-issues-notify-team.yml @@ -1,4 +1,4 @@ -# This workflow warns the team about P0 issues immediately when they are created. +# This workflow warns the team about priority: critical issues immediately when they are created. name: P0 Issue Alert on: issues: @@ -12,10 +12,10 @@ permissions: jobs: p0_notify_team: runs-on: hl-sdk-py-lin-md - # Only run for issues labeled with 'p0' (case-insensitive) + # Only run for issues labeled with 'priority: critical' (case-insensitive) if: > (github.event_name == 'issues' && ( - (github.event.label.name == 'p0' || github.event.label.name == 'P0')) + (github.event.label.name == 'priority: critical' || github.event.label.name == 'Priority: Critical')) ) steps: @@ -34,4 +34,4 @@ jobs: with: script: | const script = require('./.github/scripts/bot-p0-issues-notify-team.js'); - await script({ github, context}); + await script({ github, context });