diff --git a/Actions/TroubleShooting/TroubleShoot.Secrets.ps1 b/Actions/TroubleShooting/TroubleShoot.Secrets.ps1 index a29fc54ed..b1450068c 100644 --- a/Actions/TroubleShooting/TroubleShoot.Secrets.ps1 +++ b/Actions/TroubleShooting/TroubleShoot.Secrets.ps1 @@ -1,6 +1,6 @@ Param( [Parameter(HelpMessage = "All GitHub Secrets in compressed JSON format", Mandatory = $true)] - [string] $gitHubSecrets = "" + [PSCustomObject] $gitHubSecrets ) # @@ -25,28 +25,28 @@ function CheckSecretForCommonMistakes { if ($json.PSObject.Properties.Name.Count -gt 0) { # JSON Secrets should not contain line breaks if ($secretValue.contains("`n")) { - Write-Host "::WARNING::JSON Secret $secretName contains line breaks. JSON Secrets available to AL-Go for GitHub should be compressed JSON (i.e. NOT contain any line breaks)." + $warnings += "- Secret $secretName contains line breaks. JSON Secrets available to AL-Go for GitHub should be compressed JSON (i.e. NOT contain any line breaks)." } # JSON Secrets properties should not contain values 3 characters or less foreach($keyName in $json.PSObject.Properties.Name) { if (IsPropertySecret -propertyName $keyName) { if ($json."$keyName".Length -le 4) { - Write-Host "::WARNING::JSON Secret $secretName contains properties with very short values. These values will be masked, but the secret might be indirectly exposed and might also cause issues in AL-Go for GitHub." + $warnings += "- JSON Secret $secretName contains properties with very short values. These values will be masked, but the secret might be indirectly exposed and might also cause issues in AL-Go for GitHub." } } } } else { if ($secretValue.contains("`n")) { - Write-Host "::WARNING::Secret $secretName contains line breaks. GitHub Secrets available to AL-Go for GitHub should not contain line breaks." + $warnings += "- Secret $secretName contains line breaks. GitHub Secrets available to AL-Go for GitHub should not contain line breaks." } elseif ($secretValue.Length -le 4) { - Write-Host "::WARNING::Secret $secretName has a very short value. This value will be masked, but the secret might be indirectly exposed and might also cause issues in AL-Go for GitHub." + $warnings += "- Secret $secretName has a very short value. This value will be masked, but the secret might be indirectly exposed and might also cause issues in AL-Go for GitHub." } } } -foreach($secretName in $script:gitHubSecrets.PSObject.Properties.Name) { - $secretValue = $script:gitHubSecrets."$secretName" +foreach($secretName in $gitHubSecrets.PSObject.Properties.Name) { + $secretValue = $gitHubSecrets."$secretName" CheckSecretForCommonMistakes -secretName $secretName -secretValue $secretValue } diff --git a/Actions/TroubleShooting/TroubleShooting.ps1 b/Actions/TroubleShooting/TroubleShooting.ps1 index 9c04f14ca..9149fa311 100644 --- a/Actions/TroubleShooting/TroubleShooting.ps1 +++ b/Actions/TroubleShooting/TroubleShooting.ps1 @@ -3,6 +3,17 @@ [string] $gitHubSecrets = "" ) +$errors = @() +$warnings = @() +$suggestions = @() + . (Join-Path -Path $PSScriptRoot -ChildPath "..\AL-Go-Helper.ps1" -Resolve) -. (Join-Path -Path $PSScriptRoot -ChildPath "TroubleShoot.Secrets.ps1" -Resolve) -gitHubSecrets $gitHubSecrets +. (Join-Path -Path $PSScriptRoot -ChildPath "TroubleShoot.Secrets.ps1" -Resolve) -gitHubSecrets ($gitHubSecrets | ConvertFrom-Json) + +if ($errors.Count -eq 0) { $errors = @("No errors found") } +if ($warnings.Count -eq 0) { $warnings = @("No warnings found") } +if ($suggestions.Count -eq 0) { $suggestions = @("No suggestions found") } + +$summaryMD = (@("# Errors") + $errors + @("# Warnings") + $warnings + @("# Suggestions") + $suggestions) -join "`n`n" +Set-Content $ENV:GITHUB_STEP_SUMMARY -Value $summaryMD