diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 6ceac78..827105e 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -127,7 +127,7 @@ jobs: echo "::set-output name=isCsFilesChanged::${isCsFilesChanged}" echo "isCsFilesChanged: ${isCsFilesChanged}" generatePdfWithCode: - runs-on: ubuntu-latest + runs-on: [self-hosted, pdf-generation] needs: [findChangedCsFiles] if: ${{ needs.findChangedCsFiles.outputs.isCsFilesChanged == 'true' }} steps: @@ -139,16 +139,22 @@ jobs: - uses: actions/checkout@v1 with: submodules: true - - name: Generate PDF with code + - name: Generate PDF with code (optimized for dedicated VM) run: | export REPOSITORY_NAME=$(basename ${{ github.repository }}) wget "$SCRIPTS_BASE_URL/format-csharp-files.py" wget "$SCRIPTS_BASE_URL/format-csharp-document.sh" wget "$SCRIPTS_BASE_URL/generate-csharp-pdf.sh" bash ./generate-csharp-pdf.sh + - name: Upload PDF artifact for documentation publishing + uses: actions/upload-artifact@v3 + with: + name: generated-pdf + path: _site/Platform.${{ github.event.repository.name }}.pdf + retention-days: 1 publishDocumentation: runs-on: ubuntu-latest - needs: [findChangedCsFiles] + needs: [findChangedCsFiles, generatePdfWithCode] if: ${{ needs.findChangedCsFiles.outputs.isCsFilesChanged == 'true' }} steps: - name: Setup .NET @@ -159,11 +165,17 @@ jobs: - uses: actions/checkout@v1 with: submodules: true - - name: Publish documentation to gh-pages branch + - name: Download PDF artifact + uses: actions/download-artifact@v3 + with: + name: generated-pdf + path: _site/ + - name: Publish unified documentation to gh-pages branch + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SCRIPTS_BASE_URL: https://raw.githubusercontent.com/linksplatform/Scripts/main/MultiProjectRepository run: | export REPOSITORY_NAME=$(basename ${{ github.repository }}) - wget "$SCRIPTS_BASE_URL/docfx.json" - wget "$SCRIPTS_BASE_URL/filter.yml" - wget "$SCRIPTS_BASE_URL/toc.yml" - wget "$SCRIPTS_BASE_URL/publish-csharp-docs.sh" - bash ./publish-csharp-docs.sh + # Use local unified publishing script + chmod +x ./.scripts/publish-unified-docs.sh + bash ./.scripts/publish-unified-docs.sh diff --git a/.scripts/publish-unified-docs.sh b/.scripts/publish-unified-docs.sh new file mode 100644 index 0000000..6a19c9e --- /dev/null +++ b/.scripts/publish-unified-docs.sh @@ -0,0 +1,151 @@ +#!/bin/bash +set -e # Exit with nonzero exit code if anything fails + +# Unified documentation publishing script +# This script combines documentation generation with PDF publishing +# Based on react-deep-tree approach and existing documentation scripts + +export REPOSITORY_NAME=$(basename $(git remote get-url origin | sed 's/.*\///g' | sed 's/\.git//g')) + +echo "Publishing unified documentation for repository: $REPOSITORY_NAME" + +# Create output directory +mkdir -p _site + +# Check if PDF was generated by dedicated VM and exists +if [ -f "_site/Platform.$REPOSITORY_NAME.pdf" ]; then + echo "✓ PDF artifact found from dedicated generation VM" +else + echo "⚠ No PDF artifact found - documentation will be published without PDF" +fi + +# Generate API documentation using DocFX (if not already present) +if [ ! -d "_site/api" ]; then + echo "Generating API documentation..." + + # Download DocFX configuration if not present + if [ ! -f "docfx.json" ]; then + wget -q "$SCRIPTS_BASE_URL/docfx.json" || echo "Using default docfx configuration" + fi + + # Generate documentation + dotnet tool install -g docfx || echo "DocFX already installed" + export PATH="$PATH:$HOME/.dotnet/tools" + docfx metadata docfx.json --force || echo "Metadata generation completed with warnings" + docfx build docfx.json --force || echo "Documentation build completed" +fi + +# Create unified index page that links to both API docs and PDF +cat > _site/index.html << EOF + + +
+Comprehensive documentation and API reference
++ 🔗 GitHub Repository | + 📦 NuGet Package +
+