GitHub Action Integration
Rsdoctor provides an official GitHub rsdoctor-action for easy integration of Rsdoctor analysis functionality in CI/CD workflows. Through GitHub Action, you can automatically perform bundle diff analysis on the build output and monitor and prevent bundle degradation, continuously optimizing project performance.
Quick Start
Step 1: Install Rsdoctor Plugin in Your Project
1. Follow the Quick Start guide to install the Rsdoctor plugin in your project and configure it according to your project type.
2. You need to use Brief mode and add 'json' to the type array so that the analysis data can be uploaded in the subsequent GitHub Action. For detailed configuration, see output options.
- Example below, Rsbuild integration example:
Step 2: Configure GitHub Workflow
Create a .github/workflows/ci.yml file in your GitHub repository as shown in the example below. Please note the following points:
file_path: Required, path to the Rsdoctor JSON data file.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:
-
dispatch_target_branch: Optional, used to specify the target branch when manually triggered (workflow_dispatch). -
onindicates when the workflow runs, commonly set topull_requestandpush, and also supportsworkflow_dispatchfor manual triggering.- On
pull_request, Rsdoctor Action fetches baseline and current and performs bundle diff analysis. - On
push(i.e., after PR merge), it updates and uploads the baseline. workflow_dispatchallows you to manually trigger the workflow from the GitHub Actions page. This mode combines the behavior ofpushandpull_request: it uploads baseline data, and ifdispatch_target_branchis specified, it also performs baseline comparison analysis.
- On
-
Before executing rsdoctor-action, build your project with the Rsdoctor plugin enabled to generate the Rsdoctor JSON data file.
View Reports
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:
Additionally, clicking "Download Bundle Diff Report" allows you to download Rsdoctor's diff report for detailed diff data viewing.
For detailed Bundle Diff report content, see Bundle Diff Usage Guide.
Troubleshooting
Common Issues
Q: Action fails with "❌ Rsdoctor data file not found"
- Ensure your build process generates Rsdoctor JSON data, the default path is
/rsdoctor-data.json. - Check if file_path points to the correct location
- Verify that the Rsdoctor plugin is properly configured in your build tool
Q: If you see the message "No baseline data found", what does it mean?
- This is normal for the first run or for new repositories, because no baseline has been uploaded yet. The baseline data will be created after the first merge into the main branch.

