Skip to content

Bloat Comment

Bloat Comment #140

Workflow file for this run

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,
});
}