Skip to content

fix: SUMMARY.md 补全任务运动规划9篇章节引用 #39

fix: SUMMARY.md 补全任务运动规划9篇章节引用

fix: SUMMARY.md 补全任务运动规划9篇章节引用 #39

name: Sync to LocoWiki
on:
workflow_dispatch:
push:
branches: [main]
paths:
- '00_项目导航/**'
- '01_数学/**'
- '02_*/**'
- '03_SLAM/**'
- '04_移动机器人规控/**'
- '05_运动控制/**'
- '06_具身智能/**'
- 'SUMMARY.md'
- 'README.md'
- '.github/workflows/sync-to-locowiki.yml'
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout Robotics_Tutorial
uses: actions/checkout@v4
with:
path: source
- name: Checkout LocoWiki fork
uses: actions/checkout@v4
with:
repository: Michael-Jetson/LocoWiki
token: ${{ secrets.LOCOWIKI_PAT }}
path: target
- name: Configure git
run: |
cd target
git config user.name "Michael-Jetson"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Sync upstream
run: |
cd target
git remote add upstream https://github.com/LocoWiki/LocoWiki.git || true
git fetch upstream main
git rebase upstream/main || {
echo "::error::Rebase conflict with upstream. Manual intervention needed."
git rebase --abort
exit 1
}
- name: Create sync branch
run: |
cd target
git checkout -B contrib/robotics-tutorial
- name: Copy docs (md + images only)
run: |
TARGET_DIR="target/wiki/【体系化进阶】Robotics Tutorial"
rm -rf "$TARGET_DIR"
mkdir -p "$TARGET_DIR"
for file in README.md SUMMARY.md LICENSE; do
if [ -f "source/$file" ]; then
cp "source/$file" "$TARGET_DIR/"
fi
done
for dir in \
"00_项目导航" \
"01_数学" \
"02_C++基础与进阶" \
"03_SLAM" \
"04_移动机器人规控" \
"05_运动控制" \
"06_具身智能"
do
if [ ! -d "source/$dir" ]; then
continue
fi
mkdir -p "$TARGET_DIR/$dir"
rsync -av --delete \
--exclude='_archive/***' \
--exclude='*/_archive/***' \
--exclude='workflow/***' \
--exclude='编写规范/***' \
--exclude='*.bak' \
--exclude='*复制版本*' \
--include='*/' \
--include='*.md' \
--include='*.png' \
--include='*.jpg' \
--include='*.jpeg' \
--include='*.svg' \
--include='*.gif' \
--include='*.webp' \
--include='*.pdf' \
--exclude='*' \
"source/$dir/" "$TARGET_DIR/$dir/"
done
# Remove empty directories left by include/exclude filtering.
find "$TARGET_DIR" -type d -empty -delete
- name: List synced files
run: |
TARGET_DIR="target/wiki/【体系化进阶】Robotics Tutorial"
find "$TARGET_DIR" -type f | sort | sed "s#^$TARGET_DIR/##" | head -n 200
echo "Synced file count:"
find "$TARGET_DIR" -type f | wc -l
- name: Check for changes
id: changes
run: |
cd target
git add -A
if git diff --cached --quiet; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push
if: steps.changes.outputs.has_changes == 'true'
run: |
cd target
git commit -m "sync: update Robotics Tutorial docs from source repo
Auto-synced from Michael-Jetson/Robotics_Tutorial@${{ github.sha }}"
git push --force origin contrib/robotics-tutorial
- name: Create or update PR
if: steps.changes.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.LOCOWIKI_PAT }}
run: |
cd target
EXISTING_PR=$(gh pr list --repo LocoWiki/LocoWiki \
--head "contrib/robotics-tutorial" \
--state open --json number --jq '.[0].number' 2>/dev/null || echo "")
if [ -z "$EXISTING_PR" ] || [ "$EXISTING_PR" = "null" ]; then
gh pr create --repo LocoWiki/LocoWiki \
--head "Michael-Jetson:contrib/robotics-tutorial" \
--base main \
--title "【体系化进阶】Robotics Tutorial 文档同步" \
--body "$(cat <<'PREOF'
## Summary
自动同步来自 [Robotics_Tutorial](https://github.com/Michael-Jetson/Robotics_Tutorial) 的教学文档。
- 内容:机器人学系统化教学文档
- 作者:Pengfei Guo, DAMIAO Technology
- 协议:CC BY 4.0
- 同步范围:项目级 Markdown 文档与媒体资源
Auto-synced by GitHub Actions
PREOF
)"
echo "PR created"
else
echo "PR #$EXISTING_PR already exists, pushed new commits"
fi