forked from PaddlePaddle/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport_preview_url.sh
More file actions
42 lines (31 loc) · 1004 Bytes
/
Copy pathreport_preview_url.sh
File metadata and controls
42 lines (31 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
pr_id="$1"
if [ -z "$pr_id" ]; then
echo "Error: Pull Request ID is not provided."
exit 1
fi
generate_preview_url() {
local file_path="$1"
local pr_id="$2"
local path_no_ext="${file_path%.*}"
local base_url="http://preview-pr-${pr_id}.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/"
local final_url="${base_url}${path_no_ext}.html"
echo "$final_url"
}
mapfile -t all_git_files < <(git diff --name-only --diff-filter=ACMR develop | sed 's#^docs/##')
output_lines=()
for file in "${all_git_files[@]}"; do
if [[ "$file" == *.rst || "$file" == *.md ]]; then
url=$(generate_preview_url "$file" "$pr_id")
output_lines+=("- \`docs/${file}\`: [点击预览](${url})")
fi
done
if [ ${#output_lines[@]} -gt 0 ]; then
cat <<-EOF
<details>
<summary>📚 本次 PR 文档预览链接 (点击展开)</summary>
以下是本次 PR 中变更文档的预览链接:
$(printf '%s\n' "${output_lines[@]}")
</details>
EOF
fi