forked from hiero-ledger/hiero-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgfi_notify_team.js
More file actions
73 lines (59 loc) · 2.19 KB
/
Copy pathgfi_notify_team.js
File metadata and controls
73 lines (59 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Script to notify the team when a GFI issue is labeled.
const marker = '<!-- GFI Issue Notification -->';
const TEAM_ALIAS = '@hiero-ledger/hiero-sdk-good-first-issue-support';
async function notifyTeam(github, owner, repo, issue, message, marker) {
const comment = `${marker} :wave: Hello Team :wave:
${TEAM_ALIAS}
${message}
Repository: ${owner}/${repo} : Issue: #${issue.number} - ${issue.title || '(no title)'}
Best Regards,
Python SDK team`;
try {
await github.rest.issues.createComment({
owner,
repo,
issue_number: issue.number,
body: comment,
});
console.log(`Notified team about GFI issue #${issue.number}`);
return true;
} catch (commentErr) {
console.log(`Failed to notify team about GFI issue #${issue.number}:`, commentErr.message || commentErr);
return false;
}
}
module.exports = async ({ github, context }) => {
try {
const { owner, repo } = context.repo;
const { issue, label } = context.payload;
if (!issue?.number) return console.log('No issue in payload');
const labelName = label?.name;
if (!labelName) return;
let message = '';
if (labelName === 'Good First Issue') {
message = 'There is a new GFI in the Python SDK which is ready to be assigned';
} else if (labelName === 'Good First Issue Candidate') {
message = 'An issue in the Python SDK requires immediate attention to verify if it is a GFI and label it appropriately';
} else {
return;
}
// Check for existing comment
const comments = await github.paginate(github.rest.issues.listComments, {
owner, repo, issue_number: issue.number, per_page: 100
});
if (comments.some(c => c.body?.includes(marker))) {
return console.log(`Notification already exists for #${issue.number}`);
}
// Post notification
const success = await notifyTeam(github, owner, repo, issue, message, marker);
if (success) {
console.log('=== Summary ===');
console.log(`Repository: ${owner}/${repo}`);
console.log(`Issue Number: ${issue.number}`);
console.log(`Label: ${labelName}`);
console.log(`Message: ${message}`);
}
} catch (err) {
console.log('❌ Error:', err.message);
}
};