ci: 在 PR 评论中添加 API 文档预览链接#13
Merged
Merged
Conversation
Member
RSS1102
commented
May 13, 2026
- 更新 preview-publish.yml,在 PR 评论中显示预览地址和 API 文档链接
- 重命名 workflow 文件 test-in-tdesign-flutter.yml -> pull-request.yml
- 更新 preview-publish.yml,在 PR 评论中显示预览地址和 API 文档链接 - 重命名 workflow 文件 test-in-tdesign-flutter.yml -> pull-request.yml
There was a problem hiding this comment.
Pull request overview
该 PR 主要围绕 PR 预览构建/发布链路做拆分与增强:在构建阶段产出预览站点 artifact,并在后续 workflow_run 阶段更新 PR 评论;同时新增一个 CLI 子命令用于生成“文档变更 diff”的 Markdown 评论内容。
Changes:
- 新增
doc-diffCLI 子命令与实现:从 git 工作区变更中提取文档相关 diff,并生成可直接用于 PR 评论的 Markdown。 - 重构/重命名 PR 构建工作流:新增
pull-request.yml承担构建与产物上传,preview-publish.yml专注部署并更新预览评论,另新增doc-diff-comment.yml单独发布文档 diff 评论。 - 移除原有的预览构建 workflow(
test-in-tdesign-flutter.yml)以及多平台二进制构建/校验 workflow(build-multi-platform.yml与校验脚本)。
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/doc_diff_comment.dart | 新增:基于 git diff/status 生成文档变更 diff 的 Markdown(用于 PR 评论)。 |
| bin/main.dart | 新增命令 doc-diff,调用 DocDiffComment 输出 Markdown 文件。 |
| .github/workflows/test-in-tdesign-flutter.yml | 删除:旧的 PREVIEW_BUILD 工作流。 |
| .github/workflows/pull-request.yml | 新增:PR 构建 workflow,生成站点/示例与文档 diff,并上传 artifacts。 |
| .github/workflows/preview-publish.yml | 更新:基于 workflow_run 下载 artifacts、部署 Surge 并维护 PR 预览评论。 |
| .github/workflows/doc-diff-comment.yml | 新增:基于 workflow_run 下载文档 diff artifact,并单独维护 PR 文档 diff 评论。 |
| .github/workflows/build-multi-platform.yml | 删除:旧的多平台二进制构建与评论 workflow。 |
| .github/scripts/cross_platform_verify.dart | 删除:旧的跨平台二进制校验脚本。 |
Comments suppressed due to low confidence (2)
.github/workflows/preview-publish.yml:87
- GitHub Actions 的 job id 需要使用 ASCII(
[A-Za-z0-9_-])格式;这里使用了中文 job id(构建失败通知),会导致 workflow 校验失败无法运行。建议把 key 改为英文 job id,并将中文放到 job 的name:字段。
构建失败通知:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
.github/workflows/doc-diff-comment.yml:55
- GitHub Actions 的 job id 需要使用 ASCII(
[A-Za-z0-9_-])格式;这里使用了中文 job id(构建失败通知),会导致 workflow 校验失败无法运行。建议把 key 改为英文 job id,并将中文放到 job 的name:字段。
构建失败通知:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+64
to
+67
| bool _match(String rel) { | ||
| final name = rel.split(Platform.pathSeparator).last; | ||
| return name.endsWith('_api.md') || name == 'README.md'; | ||
| } |
Comment on lines
+69
to
+79
| Future<String> _diff(String rel) async { | ||
| final git = ['-C', repoRoot]; | ||
| final tracked = await Process.run('git', [...git, 'ls-files', '--error-unmatch', rel]); | ||
| if (tracked.exitCode == 0) { | ||
| final r = await Process.run('git', [...git, 'diff', '--no-color', '-U3', '--', rel]); | ||
| return '${r.stdout}'.trimRight().isEmpty ? '(无变更内容)' : '${r.stdout}'.trimRight(); | ||
| } | ||
| final full = '${Directory(repoRoot).path}${Platform.pathSeparator}$rel'; | ||
| final r = await Process.run('diff', ['-u', '/dev/null', full]); | ||
| return '${r.stdout}'.trimRight().isEmpty ? '(新文件)' : '${r.stdout}'.trimRight(); | ||
| } |
| - name: dart analyze | ||
| run: dart analyze --fatal-infos | ||
|
|
||
| 构建文档与预览站: |
Comment on lines
+18
to
+33
| permissions: | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| preview-success-web: | ||
| 部署预览并评论: | ||
| runs-on: ubuntu-latest | ||
| if: > | ||
| github.event.workflow_run.event == 'pull_request' && | ||
| github.event.workflow_run.conclusion == 'success' | ||
| steps: | ||
| - name: download build artifacts | ||
| uses: dawidd6/action-download-artifact@v6 | ||
| - name: 下载 PR 元数据 | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| workflow: ${{ github.event.workflow_run.workflow_id }} | ||
| run_id: ${{ github.event.workflow_run.id }} | ||
| name: build-env | ||
| name: pr-metadata | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} |
Comment on lines
21
to
24
| jobs: | ||
| preview-success-web: | ||
| 部署预览并评论: | ||
| runs-on: ubuntu-latest | ||
| if: > |
Comment on lines
+54
to
+65
| - name: 组装 PR 预览评论正文 | ||
| env: | ||
| PREVIEW_URL: ${{ steps.deploy.outputs.url }} | ||
| run: | | ||
| { | ||
| printf '%s\n' \ | ||
| "<a href=\"${PREVIEW_URL}\"><img height=\"96\" alt=\"完成\" src=\"https://user-images.githubusercontent.com/15634204/150816437-9f5bb788-cd67-4cbc-9897-b82d74e9aa65.png\" /></a>" \ | ||
| '' \ | ||
| "**预览地址**: [${PREVIEW_URL}](${PREVIEW_URL})" \ | ||
| '' \ | ||
| '<!-- AUTO_PREVIEW_HOOK -->' | ||
| } > pr-comment.md |
Comment on lines
+10
to
+25
| permissions: | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| 发布文档-diff评论: | ||
| runs-on: ubuntu-latest | ||
| if: > | ||
| github.event.workflow_run.event == 'pull_request' && | ||
| github.event.workflow_run.conclusion == 'success' | ||
| steps: | ||
| - name: 下载 PR 元数据 | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: pr-metadata | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} |
Comment on lines
+13
to
+16
| jobs: | ||
| 发布文档-diff评论: | ||
| runs-on: ubuntu-latest | ||
| if: > |
|
✅ 编译完成,产物如下:
在 Actions 运行页 Artifacts 区域按平台名称下载。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
