Compare Bundle Size #1192
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: Compare Bundle Size | |
| on: | |
| workflow_run: | |
| workflows: ['Build'] | |
| types: [completed] | |
| permissions: | |
| contents: read | |
| actions: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.workflow_run.id }} | |
| cancel-in-progress: true | |
| jobs: | |
| compare: | |
| name: Compare Bundle Stats | |
| runs-on: ubuntu-latest | |
| permissions: | |
| # Required to comment on pull requests | |
| pull-requests: write | |
| if: github.event.workflow_run.event == 'pull_request' | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0 | |
| with: | |
| egress-policy: audit | |
| - name: Git Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Download Stats (HEAD) | |
| uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 | |
| with: | |
| name: webpack-stats | |
| path: head-stats | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get Run ID from BASE | |
| id: base-run | |
| env: | |
| WORKFLOW_ID: ${{ github.event.workflow_run.workflow_id }} | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| ID=$(gh run list -c $GITHUB_SHA -w $WORKFLOW_ID -L 1 --json databaseId --jq ".[].databaseId") | |
| echo "run_id=$ID" >> $GITHUB_OUTPUT | |
| - name: Download Stats (BASE) | |
| uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 | |
| with: | |
| name: webpack-stats | |
| path: base-stats | |
| run-id: ${{ steps.base-run.outputs.run_id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Compare Bundle Size | |
| id: compare-bundle-size | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| env: | |
| HEAD_STATS_PATH: ./head-stats/webpack-stats.json | |
| BASE_STATS_PATH: ./base-stats/webpack-stats.json | |
| with: | |
| script: | | |
| const { compare } = await import('${{github.workspace}}/apps/site/scripts/compare-size/index.mjs') | |
| await compare({core}) | |
| - name: Add Comment to PR | |
| uses: thollander/actions-comment-pull-request@e2c37e53a7d2227b61585343765f73a9ca57eda9 # v3.0.0 | |
| with: | |
| comment-tag: 'compare_bundle_size' | |
| message: ${{ steps.compare-bundle-size.outputs.comment }} | |
| pr-number: ${{ github.event.workflow_run.pull_requests[0].number }} |