Report dist bundle size changes in PR #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| - name: Build | |
| run: npm run build | |
| env: | |
| NODE_ENV: production | |
| SKIP_GIT_TAG_RESOLUTION: true | |
| - name: Run size comparison | |
| run: | | |
| node .github/scripts/compare-packages-size.js > comment.md | |
| - name: Comment PR | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const body = fs.readFileSync('./comment.md', 'utf8'); | |
| const pr_number = context.payload.workflow_run.pull_requests[0].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 | |
| }) | |
| } |