docs(site): simplify media reference installs #6226
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: Bundle Size | |
| on: | |
| pull_request: | |
| permissions: | |
| pull-requests: write | |
| jobs: | |
| pr-size: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout PR | |
| uses: actions/checkout@v5 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Restore Vite Task cache | |
| uses: actions/cache/restore@v6 | |
| with: | |
| path: node_modules/.vite/task-cache | |
| key: vite-task-${{ runner.os }}-${{ runner.arch }}-restore-only-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} | |
| restore-keys: | | |
| vite-task-${{ runner.os }}-${{ runner.arch }}-packages- | |
| - name: Build packages | |
| run: pnpm build:packages | |
| - name: Test bundle size reporting | |
| run: pnpm test:size | |
| - name: Measure bundle size | |
| run: node .github/scripts/bundle-size.js --json pr-size.json | |
| - name: Upload size data | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pr-size | |
| path: pr-size.json | |
| base-size: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout base | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.pull_request.base.sha }} | |
| - name: Checkout PR scripts | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| path: .bundle-size-pr | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version-file: '.bundle-size-pr/.nvmrc' | |
| cache: pnpm | |
| cache-dependency-path: | | |
| pnpm-lock.yaml | |
| .bundle-size-pr/pnpm-lock.yaml | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Restore Vite Task cache | |
| uses: actions/cache/restore@v6 | |
| with: | |
| path: node_modules/.vite/task-cache | |
| key: vite-task-${{ runner.os }}-${{ runner.arch }}-restore-only-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }} | |
| restore-keys: | | |
| vite-task-${{ runner.os }}-${{ runner.arch }}-packages- | |
| - name: Build and measure base | |
| run: | | |
| if [ -f .bundle-size-pr/.github/scripts/bundle-size.js ]; then | |
| pnpm --dir .bundle-size-pr --fail-if-no-match install --frozen-lockfile --ignore-scripts --filter video.js | |
| pnpm build:packages | |
| node .bundle-size-pr/.github/scripts/bundle-size.js --root . --json base-size.json | |
| else | |
| echo '[]' > base-size.json | |
| fi | |
| - name: Upload size data | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: base-size | |
| path: base-size.json | |
| report: | |
| runs-on: ubuntu-latest | |
| needs: [pr-size, base-size] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Download size data | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Generate report | |
| run: > | |
| node .github/scripts/bundle-size-report.js | |
| --pr artifacts/pr-size/pr-size.json | |
| --base artifacts/base-size/base-size.json | |
| > report.md | |
| - name: Post comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const body = fs.readFileSync('report.md', 'utf8'); | |
| const marker = '<!-- bundle-size-report -->'; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const existing = comments.find(c => c.body?.startsWith(marker)); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body, | |
| }); | |
| } |