module/problem-matcher.psm1
#Requires -PSEdition Core #Requires -Version 7.2 Import-Module -Name ( @( 'command-base.psm1' ) | ForEach-Object -Process { Join-Path -Path $PSScriptRoot -ChildPath $_ } ) -Prefix 'GitHubActions' -Scope 'Local' <# .SYNOPSIS GitHub Actions - Add Problem Matcher .DESCRIPTION Add problem matcher, a way to scan the output of actions for a specified regular expression pattern and automatically surface that information prominently in the user interface, both annotation and log decoration are created when a match is detected. For more information, please visit https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md. .PARAMETER Path Relative path to the JSON file problem matcher. .PARAMETER LiteralPath Relative literal path to the JSON file problem matcher. .OUTPUTS [Void] #> Function Add-ProblemMatcher { [CmdletBinding(DefaultParameterSetName = 'Path', HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_add-githubactionsproblemmatcher#Add-GitHubActionsProblemMatcher')] [OutputType([Void])] Param ( [Parameter(Mandatory = $True, ParameterSetName = 'Path', Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][SupportsWildcards()][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Path` must be in single line string!')][Alias('File', 'Files', 'Paths')][String[]]$Path, [Parameter(Mandatory = $True, ParameterSetName = 'LiteralPath', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `LiteralPath` must be in single line string!')][Alias('LiteralFile', 'LiteralFiles', 'LiteralPaths', 'LP', 'PSPath', 'PSPaths')][String[]]$LiteralPath ) Process { ($PSCmdlet.ParameterSetName -ieq 'LiteralPath') ? $LiteralPath : ( [String[]](Resolve-Path -Path $Path) | Where-Object -FilterScript { ![String]::IsNullOrEmpty($_) } ) | ForEach-Object -Process { Write-GitHubActionsCommand -Command 'add-matcher' -Value ($_ -ireplace '^\.[\\/]', '' -ireplace '\\', '/') } } } <# .SYNOPSIS GitHub Actions - Remove Problem Matcher .DESCRIPTION Remove problem matcher that previously added from function `Add-GitHubActionsProblemMatcher`. .PARAMETER Owner Owner of the problem matcher that previously added from function `Add-GitHubActionsProblemMatcher`. .OUTPUTS [Void] #> Function Remove-ProblemMatcher { [CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_remove-githubactionsproblemmatcher#Remove-GitHubActionsProblemMatcher')] [OutputType([Void])] Param ( [Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Owner` must be in single line string!')][Alias('Identifies', 'Identify', 'Identifier', 'Identifiers', 'Key', 'Keys', 'Name', 'Names', 'Owners')][String[]]$Owner ) Process { $Owner | ForEach-Object -Process { Write-GitHubActionsCommand -Command 'remove-matcher' -Parameter @{ 'owner' = $_ } } } } Export-ModuleMember -Function @( 'Add-ProblemMatcher', 'Remove-ProblemMatcher' ) |