1515 sync :
1616 runs-on : ubuntu-latest
1717 steps :
18- - name : Checkout repo
19- uses : actions/checkout@v4
18+ - uses : actions/checkout@v4
2019
21- - name : Build wiki copy (strip .md for Wiki only )
20+ - name : Build wiki copy (strip .md only in copy )
2221 shell : bash
2322 run : |
2423 set -euo pipefail
@@ -27,29 +26,14 @@ jobs:
2726 cp -R docs/wiki/. "$build_dir"/ || true
2827 [ -f "$build_dir/Home.md" ] || printf '# Home\n\n' > "$build_dir/Home.md"
2928
30- echo "== BEFORE rewrite =="
29+ echo "== BEFORE =="
3130 grep -R --line-number -E '\]\([^)]+\.md(#[^)]*)?\)' "$build_dir" || true
3231
33- # Write small Python rewriter to a file (no heredoc!)
34- py="$build_dir/_rewrite.py"
35- printf '%s\n' \
36- " import pathlib, re, sys" \
37- " root = pathlib.Path(sys.argv[1])" \
38- " pat = re.compile(r'\\ ((?!https?://)([^)/\\ s#?]+)\\ .md(\\ #[^)]+|\\ ))')" \
39- " for p in root.rglob(\" *.md\" ): " \
40- " s = p.read_text(encoding=\" utf-8\" )" \
41- " def repl(m):" \
42- " # skip image links " \
43- " before = s.rfind(' == m.start()-1:" \
45- " return m.group(0)" \
46- " return f'({m.group(1)}{m.group(2)}'" \
47- " t = pat.sub(repl, s)" \
48- " if t != s: p.write_text(t, encoding=\" utf-8\" )" > \"$py\"
32+ # Remove .md ONLY for local links (no scheme, no slash); keep ../README.md etc.
33+ find "$build_dir" -type f -name '*.md' -print0 | xargs -0 -I{} \
34+ perl -0777 -i -pe 's/\((?!https?:\/\/)([^)\/\s#?]+)\.md(\)|#[^)]+)\)/(\1\2/g' {}
4935
50- python3 "$py" "$build_dir"
51-
52- echo "== AFTER rewrite =="
36+ echo "== AFTER =="
5337 grep -R --line-number -E '\]\([^)]+\.md(#[^)]*)?\)' "$build_dir" || true
5438
5539 - name : Push to GitHub Wiki
6448 git config user.name "github-actions[bot]"
6549 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
6650 git add -A
51+
6752 if git diff --cached --quiet; then
6853 echo "No wiki updates."; exit 0
6954 fi
55+
7056 git commit -m "Sync wiki from docs/wiki at $GITHUB_SHA"
7157 git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${REPO}.wiki.git"
7258 git -c push.forceWithLease=false push --force --no-force-with-lease origin HEAD:main || \
0 commit comments