Test-Pipelines.ps1

Get-Module AzLocal.UpdateManagement | Remove-Module -Force -ErrorAction SilentlyContinue
Get-Module AzLocal.UpdateManagement -ListAvailable | Uninstall-Module -Force -ErrorAction SilentlyContinue

Install-Module -Name AzLocal.UpdateManagement -Scope AllUsers -Force
Import-Module AzLocal.UpdateManagement -Force

Push-Location -Path "C:\Users\nebird\Repos\AzLocal.UpdateManagement"
try {
    Update-AzLocalPipelineExample `
        -Destination "C:\Users\nebird\Repos\AzLocal.UpdateManagement\.github\workflows\" `
        -Platform GitHub

    $version = (Get-Module AzLocal.UpdateManagement |
                Sort-Object Version -Descending |
                Select-Object -First 1).Version.ToString()

    git add .
    git diff --cached --quiet
    if ($LASTEXITCODE -ne 0) {
        git commit -m "Add AzLocal update workflows $version"
        git push
    } else {
        Write-Host "No changes to commit."
    }
}
finally {
    Pop-Location
}