Deploy VitePress site to Pages #39
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 Pages | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout site repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Checkout Luna-Flow docs sources | |
| env: | |
| GH_TOKEN: ${{ secrets.LUNAFLOW_DOCS_TOKEN != '' && secrets.LUNAFLOW_DOCS_TOKEN || github.token }} | |
| run: | | |
| mkdir -p ../workspace | |
| node -e "const fs=require('fs'); const cfg=JSON.parse(fs.readFileSync('docs/repo-docs.config.json','utf8')); for (const repo of cfg.repos.filter((r) => r.enabled)) console.log(repo.repo + '\t' + (repo.branch || 'main'));" | while IFS=$'\t' read -r repo branch; do | |
| echo "Fetching $repo@$branch" | |
| archive="../workspace/${repo}.tar.gz" | |
| extract_dir=$(mktemp -d) | |
| gh api "repos/Luna-Flow/$repo/tarball/$branch" > "$archive" | |
| tar -xzf "$archive" -C "$extract_dir" | |
| mv "$extract_dir"/* "../workspace/$repo" | |
| rm -rf "$extract_dir" "$archive" | |
| done | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Prepare aggregated docs | |
| env: | |
| LUNAFLOW_REPO_ROOT: ../workspace | |
| run: npm run docs:prepare | |
| - name: Build with VitePress | |
| run: npx vitepress build docs | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: docs/.vitepress/dist | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |