Skip to content

ci: 在 PR 评论中添加 API 文档预览链接#13

Merged
RSS1102 merged 16 commits into
mainfrom
feat/pr-preview-docs
May 22, 2026
Merged

ci: 在 PR 评论中添加 API 文档预览链接#13
RSS1102 merged 16 commits into
mainfrom
feat/pr-preview-docs

Conversation

@RSS1102
Copy link
Copy Markdown
Member

@RSS1102 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
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

✅ 编译完成,产物如下:

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 13, 2026

失败

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 主要围绕 PR 预览构建/发布链路做拆分与增强:在构建阶段产出预览站点 artifact,并在后续 workflow_run 阶段更新 PR 评论;同时新增一个 CLI 子命令用于生成“文档变更 diff”的 Markdown 评论内容。

Changes:

  • 新增 doc-diff CLI 子命令与实现:从 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 thread lib/doc_diff_comment.dart
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 thread lib/doc_diff_comment.dart
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();
}
Comment thread .github/workflows/pull-request.yml Outdated
- name: dart analyze
run: dart analyze --fatal-infos

构建文档与预览站:
Comment thread .github/workflows/preview-publish.yml Outdated
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 thread .github/workflows/preview-publish.yml Outdated
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 thread .github/workflows/doc-diff-comment.yml Outdated
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 thread .github/workflows/doc-diff-comment.yml Outdated
Comment on lines +13 to +16
jobs:
发布文档-diff评论:
runs-on: ubuntu-latest
if: >
@github-actions
Copy link
Copy Markdown

✅ 编译完成,产物如下:

在 Actions 运行页 Artifacts 区域按平台名称下载。

@RSS1102 RSS1102 merged commit f9098a8 into main May 22, 2026
6 checks passed
@RSS1102 RSS1102 deleted the feat/pr-preview-docs branch May 22, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants