From befadb67a56ea3302a5925439170295222eea565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Wei=C3=9F?= <72068105+Sandoun@users.noreply.github.com> Date: Fri, 7 Jul 2023 00:11:30 +0200 Subject: [PATCH] Dev (#9) * Added autodoc builder step * Added ignore badges branch for push events * Fixed doc builder --- .github/workflows/test-pipeline.yml | 23 ++++++++++++++++++++++- DocBuilder/Program.cs | 15 +++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-pipeline.yml b/.github/workflows/test-pipeline.yml index 3afbce4..8777886 100644 --- a/.github/workflows/test-pipeline.yml +++ b/.github/workflows/test-pipeline.yml @@ -9,6 +9,8 @@ on: required: false type: string push: + branches-ignore: + - badges paths-ignore: - '**.md' @@ -37,6 +39,25 @@ jobs: - name: 'Run tests' run: dotnet test "./MewtocolTests" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../Builds/TestResults/coverage.opencover.xml + - name: 'Run docbuilder' + run: dotnet run --project "./DocBuilder/DocBuilder.csproj" "./DocBuilder/Docs/plctypes.md" + + - name: 'Commit generated docs to branch' + run: | + git fetch + git checkout ${{ steps.extract_branch.outputs.branch }} + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add "./DocBuilder/Docs/plctypes.md" -f + git commit -m "(AUTO_DOC) add documentation for branch ${{ steps.extract_branch.outputs.branch }}" + + - name: 'Push docs commit' + uses: ad-m/github-push-action@master + if: ${{ success() }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ steps.extract_branch.outputs.branch }} + - name: Report Generator uses: danielpalme/ReportGenerator-GitHub-Action@5.1.22 with: @@ -74,7 +95,7 @@ jobs: git add "./Builds/TestResults/summary_${{ steps.extract_branch.outputs.branch }}.html" -f git commit -m "Add/Update badge for branch ${{ steps.extract_branch.outputs.branch }}" - - name: Push badge commit + - name: 'Push badge commit' uses: ad-m/github-push-action@master if: ${{ success() }} with: diff --git a/DocBuilder/Program.cs b/DocBuilder/Program.cs index d2dddfb..20ead02 100644 --- a/DocBuilder/Program.cs +++ b/DocBuilder/Program.cs @@ -17,8 +17,19 @@ Console.WriteLine("Building docs for PLC types..."); var entryLoc = Assembly.GetEntryAssembly(); ArgumentNullException.ThrowIfNull(entryLoc); -string filePath = Path.Combine(entryLoc.Location, @"..\..\..\..\Docs\plctypes.md"); -Console.WriteLine($"{filePath}"); +string filePath = null!; + +if(args.Length == 0) { + + filePath = Path.Combine(entryLoc.Location, @"..\..\..\..\Docs\plctypes.md"); + +} else { + + filePath = args[0]; + +} + +Console.WriteLine($"{filePath}"); StringBuilder markdownBuilder = new StringBuilder();