Skip to content

release: 3.28.0

release: 3.28.0 #13

Workflow file for this run

name: Bundle Size Comparison
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
push:
branches: [main]
jobs:
compare-size:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node 18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Run comparison (size, accuracy & speed)
id: compare
run: |
echo "COMPARE_OUTPUT<<EOF" >> $GITHUB_OUTPUT
npm run compare 2>&1 | tee -a $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
continue-on-error: false
- name: Comment PR with comparison results
if: github.event_name == 'pull_request'
env:
COMPARE_OUTPUT: ${{ steps.compare.outputs.COMPARE_OUTPUT }}
uses: actions/github-script@v7
with:
script: |
const compareOutput = process.env.COMPARE_OUTPUT;
// 查找是否已有对比评论
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(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('📦 CDN vs Local 完整对比')
);
const timestamp = new Date().toUTCString();
const body = '## 📦 CDN vs Local 完整对比\n\n```\n' +
compareOutput +
'\n```\n\n_Updated at ' + timestamp + '_\n\n---\n💡 **提示**: 此评论会在每次推送新提交时自动更新';
if (botComment) {
// 更新现有评论
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
console.log('✅ 已更新对比评论');
} else {
// 创建新评论
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
console.log('✅ 已创建对比评论');
}
- name: Display comparison in logs
if: github.event_name == 'push'
run: npm run compare