Skip to content

Commit 44670eb

Browse files
committed
fixup!
1 parent 608ef29 commit 44670eb

File tree

1 file changed

+16
-69
lines changed

1 file changed

+16
-69
lines changed

.github/workflows/bundle-compare.yml

Lines changed: 16 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -22,79 +22,26 @@ jobs:
2222
with:
2323
egress-policy: audit
2424

25-
- name: Download PR artifact (head)
26-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
25+
- name: Download Stats (HEAD)
26+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
2727
with:
28-
script: |
29-
const fs = require('fs');
28+
name: webpack-stats
29+
path: head-stats
3030

31-
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
32-
owner: context.repo.owner,
33-
repo: context.repo.repo,
34-
run_id: context.payload.workflow_run.id,
35-
});
36-
37-
const artifact = artifacts.data.artifacts.find(a => a.name === 'webpack-stats');
38-
39-
if (!artifact) {
40-
throw new Error('No artifact found!');
41-
}
42-
43-
const download = await github.rest.actions.downloadArtifact({
44-
owner: context.repo.owner,
45-
repo: context.repo.repo,
46-
artifact_id: artifact.id,
47-
archive_format: 'zip',
48-
});
49-
50-
fs.mkdirSync('head-stats', { recursive: true });
51-
fs.writeFileSync('head-stats/stats.zip', Buffer.from(download.data));
31+
- name: Get Run ID from BASE
32+
id: base-run
33+
env:
34+
WORKFLOW_ID: ${{ github.event.workflow_run.workflow_id }}
35+
run: |
36+
ID=$(gh run list -c $GITHUB_SHA -w $WORKFLOW_ID -L 1 --json databaseId --jq ".[].databaseId")
37+
echo "run_id=$ID" >> $GITHUB_OUTPUT
5238
53-
- name: Download main branch artifact (base)
54-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
39+
- name: Download Stats (BASE)
40+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
5541
with:
56-
script: |
57-
const fs = require('fs');
58-
59-
const runs = await github.rest.actions.listWorkflowRuns({
60-
owner: context.repo.owner,
61-
repo: context.repo.repo,
62-
workflow_id: context.payload.workflow_run.workflow_id,
63-
branch: 'main',
64-
status: 'completed',
65-
per_page: 1,
66-
});
67-
68-
if (runs.data.workflow_runs.length < 1) {
69-
throw new Error('No runs found!');
70-
}
71-
72-
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
73-
owner: context.repo.owner,
74-
repo: context.repo.repo,
75-
run_id: runs.data.workflow_runs[0].id,
76-
});
77-
78-
const artifact = artifacts.data.artifacts.find(a => a.name === 'webpack-stats');
79-
80-
if (!artifact) {
81-
throw new Error('No artifact found!');
82-
}
83-
84-
const download = await github.rest.actions.downloadArtifact({
85-
owner: context.repo.owner,
86-
repo: context.repo.repo,
87-
artifact_id: artifact.id,
88-
archive_format: 'zip',
89-
});
90-
91-
fs.mkdirSync('base-stats', { recursive: true });
92-
fs.writeFileSync('base-stats/stats.zip', Buffer.from(download.data));
93-
94-
- name: Unzip artifacts
95-
run: |
96-
unzip -o head-stats/stats.zip -d head-stats
97-
unzip -o base-stats/stats.zip -d base-stats
42+
name: webpack-stats
43+
path: base-stats
44+
run_id: ${{ steps.base-run.outputs.run_id }}
9845

9946
- uses: github/webpack-bundlesize-compare-action@89161bb25577f08577ce053c3264c0e3b7d7558f # v2.1.0
10047
with:

0 commit comments

Comments
 (0)