|
| 1 | +name: Build and Deploy DocFX |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + paths: |
| 7 | + - 'docs/**' |
| 8 | + - 'src/**' |
| 9 | + - 'README.md' |
| 10 | + - '.github/workflows/build-deploy-docs.yml' |
| 11 | + pull_request: |
| 12 | + branches: [ master ] |
| 13 | + paths: |
| 14 | + - 'docs/**' |
| 15 | + - 'src/**' |
| 16 | + - 'README.md' |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: pages |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + build: |
| 28 | + name: Build DocFX site |
| 29 | + runs-on: windows-latest |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Setup .NET SDK (9.x) |
| 36 | + uses: actions/setup-dotnet@v4 |
| 37 | + with: |
| 38 | + dotnet-version: '9.0.x' |
| 39 | + |
| 40 | + - name: Restore solution (fetch Uno.Sdk and packages) |
| 41 | + run: | |
| 42 | + dotnet --info |
| 43 | + dotnet restore ./src/DevTKSS.Uno.Samples.sln |
| 44 | +
|
| 45 | + - name: Install DocFX 2.78.3 |
| 46 | + run: | |
| 47 | + choco install docfx --version=2.78.3 -y |
| 48 | + docfx --version |
| 49 | +
|
| 50 | + - name: Build metadata |
| 51 | + working-directory: docs |
| 52 | + run: | |
| 53 | + docfx metadata docfx.json --logLevel Verbose |
| 54 | +
|
| 55 | + - name: Build site |
| 56 | + working-directory: docs |
| 57 | + run: | |
| 58 | + docfx build docfx.json --logLevel Verbose |
| 59 | +
|
| 60 | + - name: Prepare publish folder (gh-pages/docs) |
| 61 | + run: | |
| 62 | + New-Item -ItemType Directory -Force -Path public/docs | Out-Null |
| 63 | + robocopy "docs/_site" "public/docs" /E /NFL /NDL /NJH /NJS /NC /NS | Out-Null |
| 64 | + if (Test-Path "docs/.nojekyll") { Copy-Item -Force "docs/.nojekyll" "public/docs/.nojekyll" } |
| 65 | + shell: pwsh |
| 66 | + |
| 67 | + - name: Upload site artifact |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: docfx-site |
| 71 | + path: public/docs |
| 72 | + |
| 73 | + deploy: |
| 74 | + if: ${{ github.ref == 'refs/heads/master' && github.event_name != 'pull_request' }} |
| 75 | + name: Deploy to GitHub Pages (gh-pages/docs) |
| 76 | + needs: build |
| 77 | + runs-on: ubuntu-latest |
| 78 | + |
| 79 | + steps: |
| 80 | + - name: Checkout |
| 81 | + uses: actions/checkout@v4 |
| 82 | + with: |
| 83 | + fetch-depth: 0 |
| 84 | + |
| 85 | + - name: Download site artifact |
| 86 | + uses: actions/download-artifact@v4 |
| 87 | + with: |
| 88 | + name: docfx-site |
| 89 | + path: public/docs |
| 90 | + |
| 91 | + - name: Publish to gh-pages |
| 92 | + uses: peaceiris/actions-gh-pages@v4 |
| 93 | + with: |
| 94 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + publish_branch: gh-pages |
| 96 | + publish_dir: public |
| 97 | + keep_files: false |
| 98 | + force_orphan: true |
0 commit comments