Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 51 additions & 4 deletions .github/workflows/pull_request_create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

32 changes: 25 additions & 7 deletions .github/workflows/pull_request_merge.yml
Original file line number Diff line number Diff line change
@@ -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
Loading