From 05130ab930c8fde17e7aa0aacd86147a837cfc6f Mon Sep 17 00:00:00 2001 From: kailash-b Date: Fri, 27 Sep 2024 17:17:28 +0530 Subject: [PATCH] Generate documentation using docfx in github actions --- .github/workflows/release.yml | 48 ++++++++++++++++++++++++++++++++++- .shiprc | 1 - docs-source/docfx.json | 2 +- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a12c9a78b..89d728272 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,4 +21,50 @@ jobs: project-paths: "['src/Auth0.Core/Auth0.Core.csproj', 'src/Auth0.AuthenticationApi/Auth0.AuthenticationApi.csproj', 'src/Auth0.ManagementApi/Auth0.ManagementApi.csproj']" secrets: nuget-token: ${{ secrets.NUGET_APIKEY }} - github-token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + github-token: ${{ secrets.GITHUB_TOKEN }} + + generate-docs: + name: Generate API docs + if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')) + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + + - name: Install DocFX + run: dotnet tool install -g docfx + + - name: Build docs + run: docfx docs-source/docfx.json + + - name: Uploading Artifacts + uses: actions/upload-pages-artifact@v2 + with: + path: docs + + deploy-docs: + needs: generate-docs + name: Deploy API docs + if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/')) + + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v3 # or specific "vX.X.X" version tag for this action diff --git a/.shiprc b/.shiprc index 6a34f4886..adc2d7b6f 100644 --- a/.shiprc +++ b/.shiprc @@ -3,6 +3,5 @@ "build/common.props": [], ".version": [] }, - "postbump": "docfx docs-source/docfx.json", "prefixVersion": false } diff --git a/docs-source/docfx.json b/docs-source/docfx.json index ac60f8ac4..b571ac0c7 100644 --- a/docs-source/docfx.json +++ b/docs-source/docfx.json @@ -5,7 +5,7 @@ { "files": [ "**/*.csproj" ], "exclude": [ "**/bin/**", "**/obj/**" ], - "cwd": "../src" + "src": "../src" } ], "dest": "obj/api"