chore: sync site content from content repos #23
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 VitePress site to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| repository_dispatch: | |
| types: [content-updated] | |
| schedule: | |
| # 每20天早上8点自动检查更新(北京时间,UTC+8,所以是UTC 0点) | |
| - cron: '0 0 */20 * *' | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # For actions/checkout | |
| pages: write # For actions/deploy-pages | |
| id-token: write # For actions/deploy-pages | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| submodules: true | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 18 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Checkout content repositories | |
| run: | | |
| # Create directory for content sources | |
| mkdir -p content-source | |
| # List of content repositories | |
| repos=("AIknowledge" "auto" "book" "chinese-traditional" "cross-border" "curriculum" "edu-knowlege" "healthy" "movies" "self-media" "tools") | |
| # Clone each repository | |
| for repo in "${repos[@]}"; do | |
| echo "Cloning $repo..." | |
| git clone "https://github.com/xi7ang/$repo.git" "content-source/$repo" || { | |
| echo "Warning: Failed to clone $repo, skipping..." | |
| } | |
| done | |
| - name: Copy latest content from all repositories | |
| run: | | |
| # Set up paths | |
| export SOURCE_BASE_DIR="./content-source" | |
| export TARGET_DOCS_DIR="./docs" | |
| # Run the content synchronization | |
| bash ./copy_content.sh | |
| - name: Fetch latest commits | |
| run: npm run fetch-commits | |
| - name: Build VitePress site | |
| run: npm run build | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: ./docs/.vitepress/dist | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v5 |