docs: Fix path error #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/deploy-docs-existing-tags.yml | |
| name: Deploy Documentation - Existing Tags | |
| on: | |
| push: | |
| branches: | |
| - test # 监听 test 分支 push | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y doxygen graphviz plantuml jq | |
| - name: Set tags to deploy | |
| id: tags | |
| run: | | |
| # 一次性部署的指定 tags | |
| TAGS="v0.1.0 v0.1.2 v0.1.4" | |
| echo "tags=$TAGS" >> $GITHUB_OUTPUT | |
| echo "Deploying tags: $TAGS" | |
| - name: Build and deploy documentation | |
| env: | |
| GH_PAT: ${{ secrets.GH_PAT }} | |
| TAGS: ${{ steps.tags.outputs.tags }} | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| # 克隆文档仓库 | |
| git clone -b master https://$GH_PAT@github.com/FrozenLemonTee/original_docs.git deploy-repo | |
| for TAG in $TAGS; do | |
| echo "Processing tag: $TAG" | |
| # 检出 tag | |
| git checkout $TAG || { echo "Tag $TAG not found"; continue; } | |
| # 提取版本号 | |
| VERSION=${TAG#v} | |
| # 清理并创建文档目录 | |
| mkdir -p ../original_docs/docs/html | |
| doxygen Doxyfile > doxygen.log 2>&1 | |
| # 检查 HTML 是否生成 | |
| if [ ! -d "../original_docs/docs/html" ]; then | |
| echo "Warning: Documentation not generated for $TAG" | |
| continue | |
| fi | |
| # 创建版本信息文件 | |
| echo '<!DOCTYPE html>' > ../original_docs/docs/html/version.html | |
| echo '<html><head><title>Version Info</title></head><body>' >> ../original_docs/docs/html/version.html | |
| echo " <h1>Documentation Version</h1>" >> ../original_docs/docs/html/version.html | |
| echo " <p>Version: $VERSION</p>" >> ../original_docs/docs/html/version.html | |
| echo " <p>Tag: $TAG</p>" >> ../original_docs/docs/html/version.html | |
| echo " <p>Build Date: $(date -u)</p>" >> ../original_docs/docs/html/version.html | |
| echo " <p>Commit: $(git rev-parse $TAG)</p>" >> ../original_docs/docs/html/version.html | |
| echo '</body></html>' >> ../original_docs/docs/html/version.html | |
| # 部署到文档仓库 | |
| cd deploy-repo | |
| mkdir -p versions | |
| VERSION_DIR="versions/$VERSION" | |
| rm -rf "$VERSION_DIR" | |
| mkdir -p "$VERSION_DIR" | |
| cp -r ../../original_docs/docs/html/* "$VERSION_DIR"/ | |
| cd .. | |
| done | |
| # 更新主 index.html 和 versions/index.html | |
| cd deploy-repo | |
| echo '<!DOCTYPE html>' > index.html | |
| echo '<html><head><meta http-equiv="refresh" content="0; url=stable/index.html"></head><body>' >> index.html | |
| echo '<p>Redirecting to <a href="stable/index.html">stable documentation</a>...</p>' >> index.html | |
| echo '<p>Available versions:</p><ul>' >> index.html | |
| echo ' <li><a href="stable/index.html">Stable (master branch)</a></li>' >> index.html | |
| echo ' <li><a href="latest/index.html">Latest (test branch)</a></li>' >> index.html | |
| echo ' <li><a href="versions/">Tag versions</a></li>' >> index.html | |
| echo '</ul><p>Recent tag versions:</p><ul>' >> index.html | |
| for dir in $(ls -1 versions/ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V -r | head -5); do | |
| echo " <li><a href=\"versions/$dir/index.html\">Version $dir</a></li>" >> index.html | |
| done | |
| echo '</ul></body></html>' >> index.html | |
| # versions/index.html | |
| echo '<!DOCTYPE html>' > versions/index.html | |
| echo '<html><head><title>Versioned Documentation</title></head><body>' >> versions/index.html | |
| echo '<h1>Versioned Documentation</h1><p>Select a version:</p><ul>' >> versions/index.html | |
| for dir in $(ls -1 versions/ | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V -r); do | |
| echo " <li><a href=\"$dir/index.html\">Version $dir</a></li>" >> versions/index.html | |
| done | |
| echo '</ul><p><a href="../stable/index.html">Stable (master branch)</a></p>' >> versions/index.html | |
| echo '<p><a href="../latest/index.html">Latest (test branch)</a></p></body></html>' >> versions/index.html | |
| # 提交推送 | |
| git add . | |
| if git diff-index --quiet HEAD --; then | |
| echo "No changes to deploy" | |
| else | |
| git commit -m "Deploy documentation for tags $TAGS" | |
| git push origin master | |
| echo "✅ Documentation deployed successfully for tags $TAGS" | |
| fi |