Skip to content

Commit e9f14a3

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

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

.github/workflows/psscriptanalyzer-check.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ jobs:
2323
- name: 📦 Checkout Repository
2424
uses: actions/checkout@v4
2525

26+
- name: 🕒 Capture Metadata
27+
id: metadata
28+
shell: bash
29+
run: |
30+
echo "timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_OUTPUT
31+
echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
32+
echo "commit_msg=$(git log -1 --pretty=%B)" >> $GITHUB_OUTPUT
33+
2634
- name: 🔍 Check for PowerShell Files
2735
id: check-ps1
2836
shell: bash
@@ -175,29 +183,30 @@ jobs:
175183
run: |
176184
$summaryPath = Join-Path $env:GITHUB_WORKSPACE "psscriptanalyzer-summary.md"
177185
$sarifPath = Join-Path $env:GITHUB_WORKSPACE "psscriptanalyzer-results.sarif"
178-
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
179-
$commit = "${{ github.sha }}"
186+
$timestamp = '${{ steps.metadata.outputs.timestamp }}'
187+
$commit = '${{ steps.metadata.outputs.commit_sha }}'
188+
$commitMsg = '${{ steps.metadata.outputs.commit_msg }}'
180189
$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-
"
190+
$summary = "### 🧪 PowerShell Lint Summary`n"
191+
$summary += "- 🕒 Timestamp: $timestamp`n"
192+
$summary += "- 🔗 Commit: [$commit](https://github.com/$repo/commit/$commit)`n"
193+
$summary += "- 📝 Message: $commitMsg`n"
194+
$summary += "- 📦 Repository: [$repo](https://github.com/$repo)`n`n"
186195
187196
if (Test-Path $sarifPath) {
188197
$sarif = Get-Content $sarifPath -Raw | ConvertFrom-Json
189198
$issues = $sarif.runs[0].results
190199
if ($issues.Count -gt 0) {
191-
$summary += "\n**Detected $($issues.Count) issue(s):**\n"
200+
$summary += "**Detected $($issues.Count) issue(s):**`n"
192201
foreach ($i in $issues | Select-Object -First 10) {
193202
$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"
203+
$summary += "- [$($i.level)] `$($i.ruleId)`: $($i.message.text) ([file]($link))`n"
195204
}
196205
} else {
197-
$summary += "\n✅ No issues found."
206+
$summary += "`n✅ No issues found."
198207
}
199208
} else {
200-
$summary += "\n❗ SARIF results not found."
209+
$summary += "`n❗ SARIF results not found."
201210
}
202211
203212
$summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8

0 commit comments

Comments
 (0)