Skip to content

Commit 53cb8a3

Browse files
Update psscriptanalyzer-check.yml
Signed-off-by: LUIZ HAMILTON ROBERTO DA SILVA <[email protected]>
1 parent 7c6fa48 commit 53cb8a3

1 file changed

Lines changed: 30 additions & 25 deletions

File tree

.github/workflows/psscriptanalyzer-check.yml

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,8 @@ jobs:
134134
locations = @(
135135
@{
136136
physicalLocation = @{
137-
artifactLocation = @{
138-
uri = $_.ScriptPath.Replace("$env:GITHUB_WORKSPACE/", '')
139-
}
140-
region = @{
141-
startLine = $_.Line
142-
startColumn = $_.Column
143-
}
137+
artifactLocation = @{ uri = $_.ScriptPath.Replace("$env:GITHUB_WORKSPACE/", '') }
138+
region = @{ startLine = $_.Line; startColumn = $_.Column }
144139
}
145140
}
146141
)
@@ -149,17 +144,7 @@ jobs:
149144
$sarif = @{
150145
'$schema' = 'http://json.schemastore.org/sarif-2.1.0'
151146
version = '2.1.0'
152-
runs = @(
153-
@{
154-
tool = @{
155-
driver = @{
156-
name = 'PSScriptAnalyzer'
157-
version = $version
158-
}
159-
}
160-
results = $sarifResults
161-
}
162-
)
147+
runs = @(@{ tool = @{ driver = @{ name = 'PSScriptAnalyzer'; version = $version } }; results = $sarifResults })
163148
}
164149
$sarif | ConvertTo-Json -Depth 10 | Out-File -FilePath $sarifFile -Encoding utf8
165150
Write-Output "SARIF file generated: $sarifFile"
@@ -176,32 +161,52 @@ jobs:
176161
path: ${{ github.workspace }}/psscriptanalyzer-results.sarif
177162
retention-days: 30
178163

179-
- name: 📤 Upload SARIF to GitHub
164+
- name: 📄 Upload SARIF to GitHub
180165
if: always()
181166
uses: github/codeql-action/upload-sarif@v3
182167
with:
183168
sarif_file: ${{ github.workspace }}/psscriptanalyzer-results.sarif
184169
checkout_path: ${{ github.workspace }}
185170
wait-for-processing: true
186171

187-
- name: 📝 Generate Markdown Summary
172+
- name: 📅 Generate Markdown Summary
188173
if: always()
189174
shell: pwsh
190175
run: |
191-
$summary = "### 🧪 PowerShell Lint Summary`n"
176+
$summaryPath = Join-Path $env:GITHUB_WORKSPACE "psscriptanalyzer-summary.md"
192177
$sarifPath = Join-Path $env:GITHUB_WORKSPACE "psscriptanalyzer-results.sarif"
178+
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
179+
$commit = "${{ github.sha }}"
180+
$repo = "${{ github.repository }}"
181+
$summary = "### 🧪 PowerShell Lint Summary
182+
Run Timestamp: $timestamp
183+
Commit: [$commit](https://github.com/$repo/commit/$commit)
184+
Repository: [$repo](https://github.com/$repo)
185+
"
186+
193187
if (Test-Path $sarifPath) {
194188
$sarif = Get-Content $sarifPath -Raw | ConvertFrom-Json
195189
$issues = $sarif.runs[0].results
196190
if ($issues.Count -gt 0) {
197-
$summary += "`n**Detected $($issues.Count) issue(s):**`n"
191+
$summary += "\n**Detected $($issues.Count) issue(s):**\n"
198192
foreach ($i in $issues | Select-Object -First 10) {
199-
$summary += "- [$($i.level)] `$($i.ruleId)`: $($i.message.text)`n"
193+
$link = "https://github.com/$repo/blob/$commit/$($i.locations[0].physicalLocation.artifactLocation.uri)#L$($i.locations[0].physicalLocation.region.startLine)"
194+
$summary += "- [$($i.level)] `$($i.ruleId)`: $($i.message.text) ([file]($link))\n"
200195
}
201196
} else {
202-
$summary += "`n✅ No issues found."
197+
$summary += "\n✅ No issues found."
203198
}
204199
} else {
205-
$summary += "`n❗ SARIF results not found."
200+
$summary += "\n❗ SARIF results not found."
206201
}
202+
207203
$summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8
204+
$summary | Out-File -FilePath $summaryPath -Encoding utf8
205+
206+
- name: 🗂️ Upload Markdown Summary Artifact
207+
if: always()
208+
uses: actions/upload-artifact@v4
209+
with:
210+
name: psscriptanalyzer-markdown-summary
211+
path: ${{ github.workspace }}/psscriptanalyzer-summary.md
212+
retention-days: 30

0 commit comments

Comments
 (0)