2929 run : |
3030 echo "timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
3131 echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
32- echo "commit_msg=$(git log -1 --pretty=%B | tr -d '\r' | tr -d '\n')" >> $GITHUB_OUTPUT
32+ echo "commit_msg<<EOF" >> $GITHUB_OUTPUT
33+ git log -1 --pretty=%B >> $GITHUB_OUTPUT
34+ echo "EOF" >> $GITHUB_OUTPUT
3335
3436 - name : 🔍 Check for PowerShell Files
3537 id : check-ps1
7476 }
7577 }
7678 Invoke-ScriptAnalyzer @htPSA
77- Write-Output "Auto-fix completed."
79+ Write-Output "Auto-fix completed for indentation and whitespace ."
7880
7981 - name : 📝 Commit Auto-Fixed Files
8082 if : github.event_name == 'push'
@@ -132,7 +134,6 @@ jobs:
132134 Write-Error "PSScriptAnalyzer found errors"
133135 exit 1
134136 }
135-
136137 if ($results) {
137138 Write-Output "Found $($results.Count) issue(s)."
138139 $sarifResults = $results | ForEach-Object {
@@ -150,26 +151,13 @@ jobs:
150151 )
151152 }
152153 }
153-
154154 $sarif = @{
155155 '$schema' = 'http://json.schemastore.org/sarif-2.1.0'
156- version = '2.1.0'
157- runs = @(
158- @{
159- tool = @{
160- driver = @{
161- name = 'PSScriptAnalyzer'
162- version = $version
163- }
164- }
165- results = $sarifResults
166- }
167- )
156+ version = '2.1.0'
157+ runs = @(@{ tool = @{ driver = @{ name = 'PSScriptAnalyzer'; version = $version } }; results = $sarifResults })
168158 }
169159 $sarif | ConvertTo-Json -Depth 10 | Out-File -FilePath $sarifFile -Encoding utf8
170- Write-Output "SARIF file generated: $sarifFile"
171160 } else {
172- Write-Output "No issues found."
173161 '{"$schema": "http://json.schemastore.org/sarif-2.1.0", "version": "2.1.0", "runs": []}' | Out-File -FilePath $sarifFile -Encoding utf8
174162 }
175163
@@ -200,31 +188,33 @@ jobs:
200188 $commitMsg = '${{ steps.metadata.outputs.commit_msg }}'
201189 $repo = "${{ github.repository }}"
202190
203- $summary = @"
204- # ## 🧪 PowerShell Lint Summary
205- - 🕒 Timestamp : $timestamp
206- - 🔗 Commit : [$commit](https://github.com/$repo/commit/$commit)
207- - 📝 Message : $commitMsg
208- - 📦 Repository : [$repo](https://github.com/$repo)
209-
210- " @
191+ $summaryLines = @()
192+ $summaryLines += "### 🧪 PowerShell Lint Summary"
193+ $summaryLines += "- 🕒 **Timestamp:** $timestamp"
194+ $summaryLines += "- 🔗 **Commit:** [$commit](https://github.com/$repo/commit/$commit)"
195+ $summaryLines += "- 📝 **Message:** $commitMsg"
196+ $summaryLines += "- 📦 **Repository:** [$repo](https://github.com/$repo)"
197+ $summaryLines += ""
211198
212199 if (Test-Path $sarifPath) {
213200 $sarif = Get-Content $sarifPath -Raw | ConvertFrom-Json
214201 $issues = $sarif.runs[0].results
215202 if ($issues.Count -gt 0) {
216- $summary += " **Detected $($issues.Count) issue(s):**`n "
203+ $summaryLines += "**Detected $($issues.Count) issue(s):**"
217204 foreach ($i in $issues | Select-Object -First 10) {
218- $link = "https://github.com/$repo/blob/$commit/$($i.locations[0].physicalLocation.artifactLocation.uri)#L$($i.locations[0].physicalLocation.region.startLine)"
219- $summary += "- [$($i.level)] `$($i.ruleId)` : $($i.message.text) ([file]($link))`n"
205+ $file = $i.locations[0].physicalLocation.artifactLocation.uri
206+ $line = $i.locations[0].physicalLocation.region.startLine
207+ $link = "https://github.com/$repo/blob/$commit/$file#L$line"
208+ $summaryLines += "- [$($i.level)] `$($i.ruleId)`: $($i.message.text) ([file]($link))"
220209 }
221210 } else {
222- $summary += "`n ✅ No issues found."
211+ $summaryLines += "✅ No issues found."
223212 }
224213 } else {
225- $summary += "`n ❗ SARIF results not found."
214+ $summaryLines += "❗ SARIF results not found."
226215 }
227216
217+ $summary = $summaryLines -join "`n"
228218 $summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8
229219 $summary | Out-File -FilePath $summaryPath -Encoding utf8
230220
0 commit comments