Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions .github/scripts/bot-p0-issues-notify-team.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
// Script to notify the team when a P0 issue is created.

const CRITICAL_LABEL = 'priority: critical';
const marker = '<!-- P0 Issue Notification -->';

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 {
Expand All @@ -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, {
Expand All @@ -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 ===');
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/bot-p0-issues-notify-team.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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'))
)
Comment thread
manishdait marked this conversation as resolved.

steps:
Expand All @@ -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 });
Loading