-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-security-report.js
44 lines (38 loc) · 1.14 KB
/
run-security-report.js
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
const processor = require('./.github/scripts/process-security-results.js');
async function updatePR() {
// Get the comment content
const result = await processor.run();
// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(c =>
c.user.type === 'Bot' &&
c.body.includes(result.title)
);
const commentBody = `# ${result.title}\n${result.body}`;
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
}
}
// Execute the async function
updatePR().catch(error => {
console.error('Failed to process security results:', error);
process.exit(1);
});