Skip to content

Clean up and formatting #16

Clean up and formatting

Clean up and formatting #16

Workflow file for this run

name: Packages size analysis
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
permissions:
contents: read
pull-requests: write
actions: read
jobs:
analyze:
if: github.repository == 'rameel/ramstack.alpinegear.js'
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Checkout
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --include=dev
- name: Prepate report path
run: echo "SIZE_REPORT_OUTPUT=$RUNNER_TEMP/comment-${{ github.event.pull_request.number }}.md" >> $GITHUB_ENV
- name: Run size comparison
run: npm run size-report
env:
NODE_ENV: production
SKIP_GIT_TAG_RESOLUTION: true
- name: Comment PR
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const body = fs.readFileSync(process.env.SIZE_REPORT_OUTPUT, 'utf8');
const pr_number = context.issue.number;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr_number
});
const marker = "### 📦 Bundle size comparison";
const existing_comment = comments.find(c => c.body.includes(marker));
if (existing_comment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing_comment.id,
body: body
});
}
else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
}