|
23 | 23 | - name: 📦 Checkout Repository |
24 | 24 | uses: actions/checkout@v4 |
25 | 25 |
|
| 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 | +
|
26 | 34 | - name: 🔍 Check for PowerShell Files |
27 | 35 | id: check-ps1 |
28 | 36 | shell: bash |
@@ -175,29 +183,30 @@ jobs: |
175 | 183 | run: | |
176 | 184 | $summaryPath = Join-Path $env:GITHUB_WORKSPACE "psscriptanalyzer-summary.md" |
177 | 185 | $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 }}' |
180 | 189 | $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" |
186 | 195 |
|
187 | 196 | if (Test-Path $sarifPath) { |
188 | 197 | $sarif = Get-Content $sarifPath -Raw | ConvertFrom-Json |
189 | 198 | $issues = $sarif.runs[0].results |
190 | 199 | if ($issues.Count -gt 0) { |
191 | | - $summary += "\n**Detected $($issues.Count) issue(s):**\n" |
| 200 | + $summary += "**Detected $($issues.Count) issue(s):**`n" |
192 | 201 | foreach ($i in $issues | Select-Object -First 10) { |
193 | 202 | $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" |
195 | 204 | } |
196 | 205 | } else { |
197 | | - $summary += "\n✅ No issues found." |
| 206 | + $summary += "`n✅ No issues found." |
198 | 207 | } |
199 | 208 | } else { |
200 | | - $summary += "\n❗ SARIF results not found." |
| 209 | + $summary += "`n❗ SARIF results not found." |
201 | 210 | } |
202 | 211 |
|
203 | 212 | $summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 |
|
0 commit comments