Skip to content

Commit 501f282

Browse files
Update psscriptanalyzer-check.yml
Signed-off-by: LUIZ HAMILTON ROBERTO DA SILVA <[email protected]>
1 parent 027626c commit 501f282

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/psscriptanalyzer-check.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ jobs:
4949
shell: pwsh
5050
run: |
5151
$ErrorActionPreference = 'Stop'
52-
$sarifFile = "${{ github.workspace }}/psscriptanalyzer-results.sarif"
52+
$sarifFile = Join-Path $env:GITHUB_WORKSPACE "psscriptanalyzer-results.sarif"
5353
Write-Output "Target SARIF file path: $sarifFile"
5454
Write-Output "Checking PowerShell version:"
5555
$PSVersionTable | Format-Table -AutoSize | Out-String | Write-Output
5656
try {
5757
Write-Output "Installing PSScriptAnalyzer"
5858
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser -MinimumVersion 1.22.0 -ErrorAction Stop
59-
Write-Output "PSScriptAnalyzer version: $(Get-Module -ListAvailable PSScriptAnalyzer | Select-Object -ExpandProperty Version)"
59+
$version = (Get-Module -ListAvailable PSScriptAnalyzer)[0].Version.ToString()
60+
Write-Output "PSScriptAnalyzer version: $version"
6061
$scriptFiles = Get-ChildItem -Path . -Recurse -Include *.ps1
6162
if ($scriptFiles) {
6263
Write-Output "Found $($scriptFiles.Count) PowerShell scripts"
@@ -101,7 +102,9 @@ jobs:
101102
locations = @(
102103
@{
103104
physicalLocation = @{
104-
artifactLocation = @{ uri = $_.ScriptPath.Replace(${{ github.workspace }} + '/', '') }
105+
artifactLocation = @{
106+
uri = $_.ScriptPath.Replace("$env:GITHUB_WORKSPACE/", '')
107+
}
105108
region = @{
106109
startLine = $_.Line
107110
startColumn = $_.Column
@@ -116,7 +119,12 @@ jobs:
116119
version = '2.1.0'
117120
runs = @(
118121
@{
119-
tool = @{ driver = @{ name = 'PSScriptAnalyzer'; version = "$(Get-Module -ListAvailable PSScriptAnalyzer | Select-Object -ExpandProperty Version)" } }
122+
tool = @{
123+
driver = @{
124+
name = 'PSScriptAnalyzer'
125+
version = $version
126+
}
127+
}
120128
results = $sarifResults
121129
}
122130
)

0 commit comments

Comments
 (0)