-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
70 lines (60 loc) · 2.31 KB
/
bundle-compare.yml
File metadata and controls
70 lines (60 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Compare Bundle Size
on:
workflow_run:
workflows: ['Build']
types: [completed]
permissions:
contents: read
actions: read
# To create the comment
pull-requests: write
jobs:
compare:
name: Compare Bundle Stats
runs-on: ubuntu-latest
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
- 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 }}