Skip to content

Commit a43d386

Browse files
tannaya7AntonioCeppellini
authored andcommitted
refactor(ci/cd): update P0 bot to use priority: critical label (hiero-ledger#2149)
Signed-off-by: tannaya7 <tannayasupriya157@gmail.com>
1 parent b838709 commit a43d386

2 files changed

Lines changed: 29 additions & 23 deletions

File tree

.github/scripts/bot-p0-issues-notify-team.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
// Script to notify the team when a P0 issue is created.
22

3+
const CRITICAL_LABEL = 'priority: critical';
34
const 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}
1016
Please prioritize this issue accordingly.
1117
1218
Best Regards,
1319
Automated 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

3036
module.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 ===');

.github/workflows/bot-p0-issues-notify-team.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This workflow warns the team about P0 issues immediately when they are created.
1+
# This workflow warns the team about priority: critical issues immediately when they are created.
22
name: P0 Issue Alert
33
on:
44
issues:
@@ -12,10 +12,10 @@ permissions:
1212
jobs:
1313
p0_notify_team:
1414
runs-on: hl-sdk-py-lin-md
15-
# Only run for issues labeled with 'p0' (case-insensitive)
15+
# Only run for issues labeled with 'priority: critical' (case-insensitive)
1616
if: >
1717
(github.event_name == 'issues' && (
18-
(github.event.label.name == 'p0' || github.event.label.name == 'P0'))
18+
(github.event.label.name == 'priority: critical' || github.event.label.name == 'Priority: Critical'))
1919
)
2020
2121
steps:
@@ -34,4 +34,4 @@ jobs:
3434
with:
3535
script: |
3636
const script = require('./.github/scripts/bot-p0-issues-notify-team.js');
37-
await script({ github, context});
37+
await script({ github, context });

0 commit comments

Comments
 (0)