documentation #6
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: documentation | |
| on: | |
| push: | |
| branches: | |
| # - "develop/**" # For development and testing | |
| - "master" | |
| paths: | |
| # Documentation | |
| # Doc - CI workflow | |
| - ".github/workflows/documentation.yaml" | |
| - "scripts/ci/**documentation**.sh" | |
| # Doc - Font-End config | |
| - "docs_with_docusarus/package.json" | |
| - "docs_with_docusarus/pnpm-lock.yaml" | |
| # Doc - Docusaurus config | |
| - "docs_with_docusarus/docusaurus.config.ts" | |
| # Doc - Content | |
| - "docs_with_docusarus/**/*.md" | |
| - "docs_with_docusarus/**/*.mdx" | |
| - "docs_with_docusarus/**/*.ts" | |
| - "docs_with_docusarus/**/*.tsx" | |
| - "docs_with_docusarus/**/*.js" | |
| - "docs_with_docusarus/**/*.jsx" | |
| - "docs_with_docusarus/**/*.css" | |
| # Doc - versioning (Docusaurus versioned content) | |
| - "docs_with_docusarus/*_versions.json" | |
| - "docs_with_docusarus/*_versioned_docs/**" | |
| - "docs_with_docusarus/*_versioned_sidebars/**" | |
| workflow_run: | |
| workflows: ["release"] | |
| types: [completed] | |
| branches: ["master"] | |
| permissions: | |
| contents: write | |
| id-token: write | |
| pages: write | |
| # Allow one concurrent deployment | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| jobs: | |
| # Guard job: Check if documentation files changed and if release workflow succeeded | |
| check_docs_changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_deploy: ${{ steps.check_changes.outputs.should_deploy || steps.set_push_deploy.outputs.should_deploy }} | |
| steps: | |
| - name: Set deployment flag for push events | |
| id: set_push_deploy | |
| if: github.event_name == 'push' | |
| run: | | |
| echo "Direct push event detected, proceeding with deployment" | |
| echo "should_deploy=true" >> $GITHUB_OUTPUT | |
| - name: Download docs update flag from release workflow | |
| if: github.event_name == 'workflow_run' | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: release-docs-flag | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| run-id: ${{ github.event.workflow_run.id }} | |
| - name: Check release workflow success and docs update flag | |
| id: check_changes | |
| if: github.event_name == 'workflow_run' | |
| run: | | |
| set -euo pipefail | |
| # Verify release workflow succeeded | |
| if [[ "${{ github.event.workflow_run.conclusion }}" != "success" ]]; then | |
| echo "Release workflow failed, skipping documentation deployment" | |
| echo "should_deploy=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Read docs update flag from artifact | |
| DOCS_UPDATED=$(cat docs_updated.txt) | |
| echo "Documentation updated flag: $DOCS_UPDATED" | |
| if [[ "$DOCS_UPDATED" == "true" ]]; then | |
| echo "Documentation was updated during release, proceeding with deployment" | |
| echo "should_deploy=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "No documentation files were updated, skipping deployment" | |
| echo "should_deploy=false" >> $GITHUB_OUTPUT | |
| fi | |
| deploy_documentation: | |
| runs-on: ubuntu-latest | |
| # Run based on the check_docs_changes job output (which handles both push and workflow_run events) | |
| if: needs.check_docs_changes.outputs.should_deploy == 'true' | |
| needs: [check_docs_changes] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| # Setup pnpm first | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| run_install: false | |
| # Then setup Node.js with pnpm cache | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: '22' | |
| cache: 'pnpm' | |
| cache-dependency-path: docs_with_docusarus/pnpm-lock.yaml | |
| - name: Install dependencies | |
| working-directory: docs_with_docusarus | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Build website | |
| working-directory: docs_with_docusarus | |
| run: pnpm build | |
| # Setup Pages | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| # Upload artifact | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: ./docs_with_docusarus/build | |
| # Deploy to GitHub Pages | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |