|
| 1 | +name: Compare Bundle Size |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ['Build'] |
| 6 | + types: [completed] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + actions: read |
| 11 | + # To create the comment |
| 12 | + pull-requests: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + compare: |
| 16 | + name: Compare Bundle Stats |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Harden Runner |
| 21 | + uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 |
| 22 | + with: |
| 23 | + egress-policy: audit |
| 24 | + |
| 25 | + - name: Git Checkout |
| 26 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 27 | + |
| 28 | + - name: Download Stats (HEAD) |
| 29 | + uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 |
| 30 | + with: |
| 31 | + name: webpack-stats |
| 32 | + path: head-stats |
| 33 | + run-id: ${{ github.event.workflow_run.workflow_id }} |
| 34 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + |
| 36 | + - name: Get Run ID from BASE |
| 37 | + id: base-run |
| 38 | + env: |
| 39 | + WORKFLOW_ID: ${{ github.event.workflow_run.workflow_id }} |
| 40 | + GH_TOKEN: ${{ github.token }} |
| 41 | + run: | |
| 42 | + ID=$(gh run list -c $GITHUB_SHA -w $WORKFLOW_ID -L 1 --json databaseId --jq ".[].databaseId") |
| 43 | + echo "run_id=$ID" >> $GITHUB_OUTPUT |
| 44 | +
|
| 45 | + - name: Download Stats (BASE) |
| 46 | + uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 |
| 47 | + with: |
| 48 | + name: webpack-stats |
| 49 | + path: base-stats |
| 50 | + run-id: ${{ steps.base-run.outputs.run_id }} |
| 51 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + |
| 53 | + - name: Compare Bundle Size |
| 54 | + id: compare-bundle-size |
| 55 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
| 56 | + env: |
| 57 | + HEAD_STATS_PATH: ./head-stats/webpack-stats.json |
| 58 | + BASE_STATS_PATH: ./base-stats/webpack-stats.json |
| 59 | + with: |
| 60 | + script: | |
| 61 | + const { compare } = await import('${{github.workspace}}/apps/site/scripts/compare-size/index.mjs') |
| 62 | + await compare({core}) |
| 63 | +
|
| 64 | + - name: Add Comment to PR |
| 65 | + uses: thollander/actions-comment-pull-request@e2c37e53a7d2227b61585343765f73a9ca57eda9 # v3.0.0 |
| 66 | + with: |
| 67 | + comment-tag: 'compare_bundle_size' |
| 68 | + message: ${{ steps.compare-bundle-size.outputs.comment }} |
0 commit comments