diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..d06d634 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,72 @@ +name: Deploy Docusaurus site to GitHub Pages + +on: + push: + branches: + - main # 当 main 分支有推送时触发部署 + workflow_dispatch: # 允许手动触发 + +jobs: + build: + runs-on: self-hosted # 绕开组织 Actions 计费(同 rdk_x_doc) + + steps: + - name: Tune Git for unstable network + run: | + git config --global http.postBuffer 524288000 + git config --global http.version HTTP/1.1 + git config --global http.lowSpeedLimit 1000 + git config --global http.lowSpeedTime 600 + + - name: Checkout repository + id: checkout + uses: actions/checkout@v4 + continue-on-error: true + timeout-minutes: 15 + + - name: Retry checkout repository + if: steps.checkout.outcome != 'success' + uses: actions/checkout@v4 + timeout-minutes: 15 + + - name: Detect local Node.js on runner + id: detect_node + run: | + if command -v node >/dev/null 2>&1 && command -v npm >/dev/null 2>&1; then + echo "has_node=true" >> "$GITHUB_OUTPUT" + echo "Using local Node.js:" + node -v + npm -v + else + echo "has_node=false" >> "$GITHUB_OUTPUT" + fi + + - name: Setup Node.js (fallback) + if: steps.detect_node.outputs.has_node != 'true' + uses: actions/setup-node@v4 + with: + node-version: '24' + cache: 'npm' + + - name: Clean install dependencies + run: | + rm -rf node_modules + npm ci + + - name: Build Docusaurus site + run: npm run build + + - name: Set up Git config + run: | + git config --global user.email "2560288119@qq.com" + git config --global user.name "liqinglian01" + + - name: Setup SSH + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan github.com >> ~/.ssh/known_hosts + + - name: Deploy to GitHub Pages + run: USE_SSH=true npm run deploy diff --git a/docusaurus.config.js b/docusaurus.config.js index fdffc29..edc9839 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -15,7 +15,8 @@ const config = { url: "https://developer.d-robotics.cc", // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' - baseUrl: "/docs/", + // baseUrl 与各兄弟仓一致取 repo 名(//),产物最终进 gh-pages 的 /xburn_doc 子路径 + baseUrl: "/xburn_doc/", // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these. @@ -76,7 +77,7 @@ const config = { logo: { alt: "地瓜机器人社区 logo", src: "img/logo.png", - href: "https://d-robotics.cc/", // 修改为文档根路径 + href: "https://d-robotics.cc/", // brand 由 src/theme/Navbar/Logo swizzle 接管,此 href 不生效 }, items: [ {