Sync Documentation and Deploy #243
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: Sync Documentation and Deploy | |
| on: | |
| # Run daily at 2 AM UTC | |
| schedule: | |
| - cron: '0 2 * * *' | |
| # Allow manual triggering | |
| workflow_dispatch: | |
| inputs: | |
| skip_discovery: | |
| description: 'Skip repository discovery' | |
| required: false | |
| type: boolean | |
| default: false | |
| clean_build: | |
| description: 'Clean build (remove cache)' | |
| required: false | |
| type: boolean | |
| default: false | |
| # Trigger from other raibid-labs repositories | |
| repository_dispatch: | |
| types: [docs-updated, release-published] | |
| # Run on push to main branch | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'content/**' | |
| - 'scripts/**' | |
| - 'config/**' | |
| - '.github/workflows/**' | |
| - 'quartz.config.ts' | |
| # Sets permissions of the GITHUB_TOKEN | |
| permissions: | |
| contents: write | |
| # Allow only one concurrent deployment | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| sync-build-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Setup Nushell | |
| uses: hustcer/setup-nu@v3 | |
| with: | |
| version: '*' | |
| - name: Verify GitHub CLI authentication | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: gh auth status | |
| - name: Install dependencies | |
| run: npm ci || npm install | |
| - name: Make scripts executable | |
| run: chmod +x scripts/*.nu | |
| - name: Discover repositories | |
| if: ${{ !inputs.skip_discovery }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: nu scripts/discover-repos.nu --org raibid-labs --verbose | |
| - name: Sync submodules | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| nu scripts/sync-submodules.nu --verbose | |
| - name: Update documentation | |
| run: nu scripts/update-docs.nu --generate-index --verbose | |
| - name: Build Rust documentation index | |
| run: nu scripts/build-rustdoc.nu --output public/rustdoc.json --verbose | |
| - name: Commit submodule changes | |
| run: | | |
| git add .gitmodules content/projects | |
| if ! git diff --cached --quiet; then | |
| git commit -m "chore: update documentation submodules [skip ci]" || echo "No changes to commit" | |
| git push || echo "No changes to push" | |
| else | |
| echo "No submodule changes to commit" | |
| fi | |
| - name: Clean build cache | |
| if: ${{ inputs.clean_build }} | |
| run: | | |
| rm -rf public .quartz-cache | |
| - name: Build with Quartz | |
| run: npx quartz build | |
| - name: Deploy to gh-pages | |
| run: | | |
| cd public | |
| git init | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git commit -m "Deploy documentation - $(date +'%Y-%m-%d %H:%M:%S')" | |
| git push -f https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:gh-pages | |
| - name: Report status | |
| if: success() | |
| run: | | |
| echo "✅ Documentation sync and deployment completed successfully" | |
| echo "🌐 Site will be available at: https://raibid-labs.github.io/docs" | |
| if [ "${{ github.event_name }}" = "repository_dispatch" ]; then | |
| echo "🔔 Triggered by: ${{ github.event.client_payload.repository }}" | |
| echo "📦 Event type: ${{ github.event.action }}" | |
| fi |