Skip to content

Commit e83502a

Browse files
authored
chore: update action docs (#1388)
1 parent bd3db5b commit e83502a

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

packages/document/docs/en/guide/start/action.mdx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,23 @@ export default defineConfig({
5252
Create a `.github/workflows/ci.yml` file in your GitHub repository as shown in the example below. Please note the following points:
5353

5454
- `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:
56+
57+
```yaml
58+
target_branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.event.repository.default_branch }}
59+
```
60+
61+
- `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.
5865

5966
```yaml
6067
name: Bundle Analysis
6168
62-
on: [pull_request, push]
69+
on:
70+
pull_request:
71+
types: [opened, synchronize, reopened, closed]
6372
6473
jobs:
6574
bundle-analysis:
@@ -100,16 +109,11 @@ jobs:
100109
uses: web-infra-dev/rsdoctor-action@main
101110
with:
102111
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:
113+
# ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.event.repository.default_branch }}
114+
target_branch: 'main'
104115
```
105116

106-
#### Configuration Options
107-
108-
In the above configuration:
109-
110-
- `file_path`: Required, path to the Rsdoctor JSON data file.
111-
- `target_branch`: Optional, target branch name, defaults to 'main'.
112-
113117
## View Reports
114118

115119
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:

packages/document/docs/zh/guide/start/action.mdx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ export default defineConfig({
5252
在你的 GitHub 仓库中创建 `.github/workflows/ci.yml` 文件,如下示例。需要注意以下几点:
5353

5454
- `file_path`:必需,Rsdoctor JSON 数据文件路径。
55-
- `target_branch`:非必需,目标分支名称,默认是 'main'。
55+
- `target_branch`:非必需,目标分支名称,默认是 'main'。如果想用不固定的目标分支,即自动获取当前 pull request 的 target branch,而不是固定的主分支,则可以使用下方配置:
56+
57+
```yaml
58+
target_branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.event.repository.default_branch }}
59+
```
60+
5661
- `on` 是指 workflow 运行的时机,通常设置为 `pull_request` 和 `push`。
5762
- 在 `pull_request` 时,Rsdoctor Action 会拉取 baseline 和 current,进行 bundle diff 分析。
5863
- 在 `push`(即 PR 合并)时,会进行 baseline 的更新和上传操作。
@@ -61,7 +66,9 @@ export default defineConfig({
6166
```yaml
6267
name: Bundle Analysis
6368
64-
on: [pull_request, push]
69+
on:
70+
pull_request:
71+
types: [opened, synchronize, reopened, closed]
6572
6673
jobs:
6774
bundle-analysis:
@@ -102,7 +109,9 @@ jobs:
102109
uses: web-infra-dev/rsdoctor-action@main
103110
with:
104111
file_path: 'dist/.rsdoctor/rsdoctor-data.json'
105-
target_branch: ${{ github.ref_name }}
112+
# 默认 'main',如果想用不固定的目标分支,即自动获取当前 pull request 的 target branch,则可以使用下方配置:
113+
# ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.event.repository.default_branch }}
114+
target_branch: 'main'
106115
```
107116

108117
## 查看报告

0 commit comments

Comments
 (0)