This commit is contained in:
Bernie White 2023-03-15 23:04:03 +10:00 коммит произвёл GitHub
Родитель 77bf6b5df4
Коммит 647fec58a6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 35 добавлений и 1 удалений

Просмотреть файл

@ -71,6 +71,7 @@ For a list of changes please see the [change log][2].
path: string # Optional. The working directory PSRule is run from.
prerelease: boolean # Optional. Determine if a pre-release module version is installed.
repository: string # Optional. The name of the PowerShell repository where PSRule modules are installed from.
summary: boolean # Optional. Determines if a job summary is written.
version: string # Optional. The specific version of PSRule to use.
```
@ -185,6 +186,12 @@ For details PowerShell repositories see [Working with Private PowerShellGet Repo
[4]: https://docs.microsoft.com/powershell/scripting/gallery/how-to/working-with-local-psrepositories
### `summary`
Determines if a job summary is written.
By default, a job summary is generated and attached to the workflow run.
When set to `false` the job summary is skipped.
### `version`
The specific version of PSRule to use.

Просмотреть файл

@ -73,6 +73,11 @@ inputs:
default: 'PSGallery'
required: false
summary:
description: 'Determines if a job summary is written.'
default: 'true'
required: false
version:
description: 'The specific version of PSRule to use.'
default: ''
@ -85,4 +90,4 @@ runs:
shell: pwsh
working-directory: ${{ github.workspace }}
run: |-
${{ github.action_path }}/powershell.ps1 -InputType '${{ inputs.inputType }}' -InputPath '${{ inputs.inputPath }}' -Modules '${{ inputs.modules }}' -Source '${{ inputs.source }}' -Baseline '${{ inputs.baseline }}' -Conventions '${{ inputs.conventions }}' -Option '${{ inputs.option }}' -Outcome '${{ inputs.outcome }}' -OutputFormat '${{ inputs.outputFormat }}' -OutputPath '${{ inputs.outputPath }}' -Path '${{ inputs.path }}' -PreRelease '${{ inputs.prerelease }}' -Repository '${{ inputs.repository }}' -Version '${{ inputs.version }}'
${{ github.action_path }}/powershell.ps1 -InputType '${{ inputs.inputType }}' -InputPath '${{ inputs.inputPath }}' -Modules '${{ inputs.modules }}' -Source '${{ inputs.source }}' -Baseline '${{ inputs.baseline }}' -Conventions '${{ inputs.conventions }}' -Option '${{ inputs.option }}' -Outcome '${{ inputs.outcome }}' -OutputFormat '${{ inputs.outputFormat }}' -OutputPath '${{ inputs.outputPath }}' -Path '${{ inputs.path }}' -PreRelease '${{ inputs.prerelease }}' -Repository '${{ inputs.repository }}' -Summary '${{ inputs.summary }}' -Version '${{ inputs.version }}'

Просмотреть файл

@ -8,6 +8,10 @@ See [upgrade notes][upgrade-notes] for helpful information when upgrading from p
What's changed since v2.8.0:
- New features:
- Added job summaries to each run by @BernieWhite.
[#218](https://github.com/microsoft/ps-rule/issues/218)
- Set the `summary` input to `false` to skip generating a job summary.
- General improvements:
- Added support for action release branches by @BernieWhite.
[#214](https://github.com/microsoft/ps-rule/issues/214)

Просмотреть файл

@ -62,6 +62,10 @@ param (
# The name of the PowerShell repository where PSRule modules are installed from.
[String]$Repository = $Env:INPUT_REPOSITORY,
# Determines if a job summary is written.
[Parameter(Mandatory = $False)]
[String]$Summary = $Env:INPUT_SUMMARY,
# The specific version of PSRule to use.
[Parameter(Mandatory = $False)]
[String]$Version = $Env:INPUT_VERSION
@ -229,6 +233,7 @@ Write-Host "[info] Using Option: $Option";
Write-Host "[info] Using Outcome: $Outcome";
Write-Host "[info] Using OutputFormat: $OutputFormat";
Write-Host "[info] Using OutputPath: $OutputPath";
Write-Host "[info] Using Summary: $Summary";
try {
Push-Location -Path $Path;
@ -265,6 +270,9 @@ try {
$invokeParams['OutputPath'] = $OutputPath;
WriteDebug ([String]::Concat('-OutputFormat ', $OutputFormat, ' -OutputPath ''', $OutputPath, ''''));
}
if ($Summary -eq 'true') {
$Env:PSRULE_OUTPUT_JOBSUMMARYPATH = 'reports/ps_rule_summary.md';
}
# repository
if ($InputType -eq 'repository') {
@ -297,6 +305,16 @@ catch {
$Host.SetShouldExit(1);
}
finally {
try {
if ($Summary -eq 'true' -and (Test-Path -Path 'reports/ps_rule_summary.md')) {
Get-Content -Path 'reports/ps_rule_summary.md' -Raw > $Env:GITHUB_STEP_SUMMARY;
$Null = Remove-Item -Path 'reports/ps_rule_summary.md' -Force;
}
}
catch {
Write-Host "::warning::Failed to write job summary: $($_.Exception.Message)";
Write-Host "$($_.Exception.ScriptStackTrace)";
}
Pop-Location;
}
Write-Host '---';