You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/document/docs/en/guide/start/action.mdx
+16-12Lines changed: 16 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,14 +52,23 @@ export default defineConfig({
52
52
Create a `.github/workflows/ci.yml` file in your GitHub repository as shown in the example below. Please note the following points:
53
53
54
54
-`file_path`: Required, path to the Rsdoctor JSON data file.
55
-
-`target_branch`: Optional, target branch name, defaults to 'main'.
56
-
-`on` refers to the timing of execution. It needs to run on both `pull_request` and `push`. During `pull_request`, Rsdoctor Action will pull baseline and current data for bundle diff analysis. During `push` (i.e., when PR is merged), it will perform baseline update and upload operations.
57
-
- Before executing rsdoctor-action, you need to build the project first. During the build process, you need to enable the Rsdoctor plugin and generate the Rsdoctor JSON data file.
55
+
-`target_branch`: Optional, target branch name, defaults to 'main'. If you want to use a dynamic target branch, i.e., automatically get the target branch of the current pull request instead of a fixed main branch, you can use the following configuration:
- `on` indicates when the workflow runs, commonly set to `pull_request` and `push`.
62
+
- On `pull_request`, Rsdoctor Action fetches baseline and current and performs bundle diff analysis.
63
+
- On `push` (i.e., after PR merge), it updates and uploads the baseline.
64
+
- Before executing rsdoctor-action, build your project with the Rsdoctor plugin enabled to generate the Rsdoctor JSON data file.
58
65
59
66
```yaml
60
67
name: Bundle Analysis
61
68
62
-
on: [pull_request, push]
69
+
on:
70
+
pull_request:
71
+
types: [opened, synchronize, reopened, closed]
63
72
64
73
jobs:
65
74
bundle-analysis:
@@ -100,16 +109,11 @@ jobs:
100
109
uses: web-infra-dev/rsdoctor-action@main
101
110
with:
102
111
file_path: 'dist/.rsdoctor/rsdoctor-data.json'
103
-
target_branch: ${{ github.ref_name }}
112
+
# Default 'main'. If you want to use a dynamic target branch, i.e., automatically get the target branch of the current pull request instead of a fixed main branch, you can use the following configuration:
- `file_path`: Required, path to the Rsdoctor JSON data file.
111
-
- `target_branch`: Optional, target branch name, defaults to 'main'.
112
-
113
117
## View Reports
114
118
115
119
After submitting the above configuration file to your repository, GitHub Actions will automatically run under the specified trigger conditions and generate Rsdoctor analysis reports. You will see bundle size change comparison prompts in GitHub CI, as shown below:
0 commit comments