From ea5cb80cd3e629912c99fd3946678c90788e21cd Mon Sep 17 00:00:00 2001 From: Jeff Brown Tech Date: Sun, 22 Mar 2026 10:06:56 -0700 Subject: [PATCH] workflow updates and improvements --- .github/workflows/pull_request_create.yml | 55 +++++++++++++++++++++-- .github/workflows/pull_request_merge.yml | 32 ++++++++++--- 2 files changed, 76 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pull_request_create.yml b/.github/workflows/pull_request_create.yml index 22b6b1a..daf9cad 100644 --- a/.github/workflows/pull_request_create.yml +++ b/.github/workflows/pull_request_create.yml @@ -14,19 +14,66 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Test-ModuleManifest + - name: Install Modules + shell: pwsh run: | - Test-ModuleManifest -Path .\PowerAzPlus.psd1 + Install-Module -Name PlatyPS -Force -Scope CurrentUser + Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser + + - name: Test-ModuleManifest shell: pwsh + run: Test-ModuleManifest -Path .\PowerAzPlus.psd1 - name: Invoke-ScriptAnalyzer run: | $result = Invoke-ScriptAnalyzer -Path . -Severity Error if ($result.Count -ne 0) { Write-Output $result; exit 1} shell: pwsh + + - name: Validate Help Files for All Exported Functions + shell: pwsh + run: | + # Get exported functions from manifest + $manifest = Import-PowerShellDataFile -Path ".\PowerAzPlus.psd1" + $exportedFunctions = $manifest.FunctionsToExport + + if ($null -eq $exportedFunctions -or $exportedFunctions.Count -eq 0) { + Write-Error "No functions found in FunctionsToExport" + exit 1 + } + + # Get markdown files + $markdownFiles = Get-ChildItem -Path ".\docs" -Filter "*.md" | ForEach-Object { $_.BaseName } + + # Check each function has a markdown file + $missingDocs = @() + foreach ($function in $exportedFunctions) { + if ($markdownFiles -notcontains $function) { + $missingDocs += $function + } + } + + if ($missingDocs.Count -gt 0) { + Write-Error "Missing markdown help files for: $($missingDocs -join ', ')" + exit 1 + } + + Write-Output "✓ All $($exportedFunctions.Count) exported functions have corresponding markdown files" + + - name: Test XML Help Generation + shell: pwsh + run: | + New-ExternalHelp -Path ".\docs" -OutputPath ".\test-help" -Force + if (-not (Test-Path ".\test-help\PowerAzPlus-help.xml")) { + Write-Error "Failed to generate help XML" + exit 1 + } + Write-Output "Help XML generated successfully" - name: Test publish to PowerShell Gallery + shell: pwsh + env: + PSGalleryApiKey: ${{ secrets.POWERSHELLGALLERY_API_KEY }} run: | - $env:PSGalleryApiKey = "${{ secrets.POWERSHELLGALLERY_API_KEY }}" Publish-Module -Path . -Repository PSGallery -NuGetApiKey $env:PSGalleryApiKey -WhatIf -Verbose - shell: pwsh \ No newline at end of file + \ No newline at end of file diff --git a/.github/workflows/pull_request_merge.yml b/.github/workflows/pull_request_merge.yml index ef885ba..3240fdf 100644 --- a/.github/workflows/pull_request_merge.yml +++ b/.github/workflows/pull_request_merge.yml @@ -1,22 +1,40 @@ name: Pull Request Merge on: - pull_request: - types: - - closed + push: + branches: + - main workflow_dispatch: jobs: publish: - if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install PlatyPS + shell: pwsh + run: Install-Module -Name PlatyPS -Force -Scope CurrentUser - - name: Publish module to PowerShell Gallery + - name: Generate XML Help + shell: pwsh + run: New-ExternalHelp -Path ".\docs" -OutputPath "." -Force + + - name: Commit and Push Help Updates + shell: pwsh run: | - $env:PSGalleryApiKey = "${{ secrets.POWERSHELLGALLERY_API_KEY }}" - Publish-Module -Path . -Repository PSGallery -NuGetApiKey $env:PSGalleryApiKey + git config user.email "github-actions@github.com" + git config user.name "GitHub Actions" + git add PowerAzPlus-help.xml + git commit -m "chore: update help documentation" || echo "No changes to help file" + git push + + - name: Publish module to PowerShell Gallery shell: pwsh + env: + PSGalleryApiKey: ${{ secrets.POWERSHELLGALLERY_API_KEY }} + run: Publish-Module -Path . -Repository PSGallery -NuGetApiKey $env:PSGalleryApiKey