-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathaction.yml
More file actions
39 lines (35 loc) · 1.16 KB
/
action.yml
File metadata and controls
39 lines (35 loc) · 1.16 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
name: bundle_size_test
inputs:
cwd:
required: true
config:
required: true
runs:
using: composite
steps:
- name: Analyze build
working-directory: ${{ inputs.cwd }}
run: |-
npm run analyze-build
shell: bash
- name: Check bundle sizes
working-directory: ${{ inputs.cwd }}
# NOTE: A bug prevented us from running bundlesize with a config file:
# npx bundlesize --scope ${{ github.action_path }}/bundlesize.config.json
# For more details, see https://github.com/siddharthkp/bundlesize/issues/326
run: |-
json_string='${{ inputs.config }}'
if ! echo "$json_string" | jq '.' > /dev/null 2>&1; then
echo "::error::Invalid JSON input provided: $json_string"
exit 1
fi
# Parse the given json string and build the command to run
echo "$json_string" | jq -r 'to_entries[] | "npx bundlesize -f \"" + .key + "\" -s " + .value' | while IFS= read -r command; do
echo "Executing: $command"
eval "$command"
done
shell: bash
- name: Report bundle sizes
run: |-
node ./scripts/report-bundle-size.js ${{ inputs.cwd }}/build
shell: bash