docs(en): improve English documentation structure and SEO #26
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
| name: Deploy Documentation | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/deploy-docs.yml' | |
| tags: | |
| - 'v*' # 发布版本时触发(如 v1.0.0) | |
| workflow_dispatch: # 允许手动触发 | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| environment: docs | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # 获取所有历史记录,用于生成正确的最后更新时间 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build VitePress documentation | |
| run: npx vitepress build docs | |
| env: | |
| NODE_ENV: production | |
| - name: Verify build output | |
| run: | | |
| echo "📦 Verifying build output..." | |
| if [ ! -f "docs/.vitepress/dist/index.html" ]; then | |
| echo "❌ Build failed: index.html not found" | |
| exit 1 | |
| fi | |
| if [ ! -f "docs/.vitepress/dist/sitemap.xml" ]; then | |
| echo "❌ Build failed: sitemap.xml not found" | |
| exit 1 | |
| fi | |
| echo "✅ Build verification passed" | |
| - name: Deploy files to server | |
| uses: easingthemes/ssh-deploy@main | |
| with: | |
| SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
| REMOTE_HOST: ${{ secrets.REMOTE_HOST }} | |
| REMOTE_USER: ${{ secrets.REMOTE_USER }} | |
| SOURCE: "docs/.vitepress/dist/" | |
| TARGET: "/var/www/bingo/docs/" | |
| EXCLUDE: "/dist/, /node_modules/" | |
| SCRIPT_BEFORE: | | |
| whoami | |
| ls -la /var/www/bingo/ | |
| SCRIPT_AFTER: | | |
| echo "Deployment completed!" | |
| ls -la /var/www/bingo/docs/ | |
| echo "ℹ️ Note: Nginx configuration is NOT auto-updated. Update manually if needed." | |
| - name: Verify deployment | |
| if: success() | |
| run: | | |
| echo "🔍 Verifying deployment..." | |
| # 等待几秒让服务器更新 | |
| sleep 5 | |
| # 测试首页 | |
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://bingoctl.dev/) | |
| if [ "$HTTP_CODE" = "200" ]; then | |
| echo "✅ Homepage accessible (HTTP $HTTP_CODE)" | |
| else | |
| echo "⚠️ Homepage returned HTTP $HTTP_CODE" | |
| fi | |
| # 测试 Clean URL | |
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://bingoctl.dev/guide/what-is-bingo) | |
| if [ "$HTTP_CODE" = "200" ]; then | |
| echo "✅ Clean URLs working (HTTP $HTTP_CODE)" | |
| else | |
| echo "⚠️ Clean URL test returned HTTP $HTTP_CODE" | |
| fi | |
| # 测试重定向 | |
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://bingoctl.dev/guide/what-is-bingo.html) | |
| if [ "$HTTP_CODE" = "301" ]; then | |
| echo "✅ Redirects working (HTTP $HTTP_CODE)" | |
| else | |
| echo "⚠️ Redirect test returned HTTP $HTTP_CODE (expected 301)" | |
| fi | |
| # 测试 sitemap | |
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://bingoctl.dev/sitemap.xml) | |
| if [ "$HTTP_CODE" = "200" ]; then | |
| echo "✅ Sitemap accessible (HTTP $HTTP_CODE)" | |
| else | |
| echo "⚠️ Sitemap returned HTTP $HTTP_CODE" | |
| fi | |
| - name: Deployment notification | |
| if: success() | |
| run: | | |
| echo "======================================" | |
| echo "✅ Documentation deployed successfully!" | |
| echo "======================================" | |
| echo "🌐 Website: https://bingoctl.dev" | |
| echo "📅 Deployed at: $(date)" | |
| echo "📝 Commit: ${{ github.sha }}" | |
| echo "🔗 Clean URLs: Enabled" | |
| echo "ℹ️ Nginx config: Manual update required (if changed)" | |
| echo "======================================" | |
| - name: Deployment failed | |
| if: failure() | |
| run: | | |
| echo "❌ Documentation deployment failed" | |
| echo "Please check the logs above for errors" |