-
-
Notifications
You must be signed in to change notification settings - Fork 177
57 lines (51 loc) · 1.69 KB
/
bloat-comment.yml
File metadata and controls
57 lines (51 loc) · 1.69 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
name: Bloat Comment
on:
workflow_run:
workflows: ["CI"]
types: [completed]
jobs:
comment:
if: github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Download comment data
uses: actions/download-artifact@v7
with:
name: bloat-comment
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Post PR comment
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const prNumber = parseInt(fs.readFileSync('pr-number.txt', 'utf8').trim());
const body = fs.readFileSync('report.md', 'utf8').trim();
if (!body) {
console.log('Empty report, skipping comment.');
return;
}
const marker = '## Size Report';
const { data: comments } = await github.rest.issues.listComments({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
});
const existing = comments.find(c => c.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
comment_id: existing.id,
owner: context.repo.owner,
repo: context.repo.repo,
body,
});
} else {
await github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body,
});
}