-
Notifications
You must be signed in to change notification settings - Fork 1
112 lines (94 loc) · 4.29 KB
/
Copy pathsync-docs.yml
File metadata and controls
112 lines (94 loc) · 4.29 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Sync Documentation from Main Repo
on:
repository_dispatch:
types: [docs-updated]
workflow_dispatch:
inputs:
source_ref:
description: 'Branch or commit from source repo'
required: false
default: 'main'
jobs:
sync-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout docs repository
uses: actions/checkout@v4
with:
token: ${{ secrets.DOCS_REPO_TOKEN }}
path: docs-repo
- name: Checkout main Wegent repository
uses: actions/checkout@v4
with:
repository: wecode-ai/Wegent
ref: ${{ github.event.inputs.source_ref || 'main' }}
path: main-repo
token: ${{ secrets.DOCS_REPO_TOKEN }}
- name: Sync English documentation
run: |
# Mirror the source tree so removed pages and category files do not linger.
find docs-repo/docs -mindepth 1 -maxdepth 1 -exec rm -rf {} +
# Copy English docs
if [ -d "main-repo/docs/en" ]; then
cp -r main-repo/docs/en/* docs-repo/docs/
fi
- name: Sync Chinese documentation
run: |
# Mirror the source tree so removed pages and category files do not linger.
find docs-repo/i18n/zh/docusaurus-plugin-content-docs/current -mindepth 1 -maxdepth 1 -exec rm -rf {} +
# Copy Chinese docs
if [ -d "main-repo/docs/zh" ]; then
cp -r main-repo/docs/zh/* docs-repo/i18n/zh/docusaurus-plugin-content-docs/current/
fi
- name: Sync images
run: |
# Copy images
if [ -d "main-repo/docs/assets/images" ]; then
cp -r main-repo/docs/assets/images/* docs-repo/static/img/ 2>/dev/null || true
fi
- name: Sync examples
run: |
# Copy examples
if [ -d "main-repo/docs/examples" ]; then
mkdir -p docs-repo/static/examples
cp -r main-repo/docs/examples/* docs-repo/static/examples/ 2>/dev/null || true
fi
- name: Update image paths in documentation
run: |
cd docs-repo
# Update image paths in English docs
find docs -name "*.md" -type f -exec sed -i 's|\.\.\/\.\.\/assets\/images\/|/img/|g' {} \;
find docs -name "*.md" -type f -exec sed -i 's|\.\.\/assets\/images\/|/img/|g' {} \;
# Update image paths in Chinese docs
find i18n/zh/docusaurus-plugin-content-docs/current -name "*.md" -type f -exec sed -i 's|\.\.\/\.\.\/assets\/images\/|/img/|g' {} \;
find i18n/zh/docusaurus-plugin-content-docs/current -name "*.md" -type f -exec sed -i 's|\.\.\/assets\/images\/|/img/|g' {} \;
- name: Update example paths
run: |
cd docs-repo
# Update example paths
find docs -name "*.md" -type f -exec sed -i 's|\.\.\/examples\/|/examples/|g' {} \;
find i18n/zh/docusaurus-plugin-content-docs/current -name "*.md" -type f -exec sed -i 's|\.\.\/examples\/|/examples/|g' {} \;
- name: Fix MDX compatibility issues
run: |
cd docs-repo
# Fix <br> tags (convert to self-closing)
find docs -name "*.md" -type f -exec sed -i 's/<br>/<br\/>/gi' {} \;
find i18n/zh/docusaurus-plugin-content-docs/current -name "*.md" -type f -exec sed -i 's/<br>/<br\/>/gi' {} \;
# Fix < followed by numbers (escape for MDX)
find docs -name "*.md" -type f -exec sed -i 's/<\([0-9]\)/\<\1/g' {} \;
find i18n/zh/docusaurus-plugin-content-docs/current -name "*.md" -type f -exec sed -i 's/<\([0-9]\)/\<\1/g' {} \;
# Fix {variable} patterns outside code blocks (wrap in backticks)
find docs -name "*.md" -type f -exec sed -i 's/{model}/`{model}`/g' {} \;
find i18n/zh/docusaurus-plugin-content-docs/current -name "*.md" -type f -exec sed -i 's/{model}/`{model}`/g' {} \;
- name: Commit and push changes
run: |
cd docs-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Sync documentation from main Wegent repository"
git push
fi