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: Build and Publish Docfx Pages | |
| on: | |
| push: | |
| branches: ["master"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| publish-docs: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET 10 SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.x' | |
| - name: Restore NuGet packages | |
| run: dotnet restore HelpSense.sln | |
| - name: Install DocFX | |
| run: dotnet tool install -g docfx | |
| - name: Configure environment (add tools to PATH, set MSBuild path) | |
| shell: pwsh | |
| run: | | |
| # 将 .NET 全局工具目录加入 PATH | |
| echo "$env:USERPROFILE\.dotnet\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| # 找到最新的 .NET SDK 目录下的 MSBuild.exe | |
| $msbuildPath = (Get-ChildItem "C:\Program Files\dotnet\sdk" -Directory | Sort-Object -Descending | Select-Object -First 1).FullName + "\MSBuild.exe" | |
| # 设置环境变量 MSBUILD_EXE_PATH,DocFX 会优先使用它 | |
| echo "MSBUILD_EXE_PATH=$msbuildPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| - name: Build Documentation | |
| run: docfx docs/docfx.json | |
| env: | |
| DOCFX_ENABLE_RESTAPI_VALIDATION: false | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: 'docs/_site' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |