ci(docs-stage): 让 fork PR 也能预览(label 门控 + 只覆盖 md/html)#1635
Open
chenglu wants to merge 1 commit into
Open
Conversation
之前 docs-stage 用 on: pull_request,fork PR 拿不到部署 secret,且显式 `if: head.repo.full_name == 'cfug/flutter.cn'` 直接跳过 fork。本改动: - 改用 pull_request_target(在 base 仓库上下文运行,fork PR 也有 secret) - fork PR 默认不触发,需维护者审过内容后打 'safe to preview' 标签才构建 - 同仓库 PR 仍检出 PR head 完整预览;fork PR 只检出可信 base 代码,再用 GitHub API 把改动的 md/html(限 sites/docs/src/content/ 下、排除越界)覆盖进来, 用 base 仓库自己的 dash_site/translator 构建。绝不检出/执行 fork 代码。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AlexV525
reviewed
Jun 24, 2026
| # 只检出这些受控路径;pathspec 限定在仓库根目录下的指定文件,无法写到仓库之外 | ||
| xargs -a overlay-files.txt git checkout pr-head -- | ||
| else | ||
| echo "没有匹配的 md/html 改动,按 base 内容构建。" |
AmosHuKe
reviewed
Jun 24, 2026
| # 并排除含 .. 的越界路径与含空白的路径 | ||
| gh api --paginate "repos/${GH_REPO}/pulls/${PR_NUMBER}/files" \ | ||
| --jq '.[] | select(.status != "removed") | .filename' \ | ||
| | grep -E '^sites/docs/src/content/[^[:space:]]+\.(md|html)$' \ |
Member
There was a problem hiding this comment.
_includes 同样是文档的部分,也经常需要修改,建议也加入进来。
Suggested change
| | grep -E '^sites/docs/src/content/[^[:space:]]+\.(md|html)$' \ | |
| | grep -E '^sites/docs/src/(content|_includes)/[^[:space:]]+\.(md|html)$' \ |
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.
之前 docs-stage 用 on: pull_request,fork PR 拿不到部署 secret,且显式
if: head.repo.full_name == 'cfug/flutter.cn'直接跳过 fork。本改动: