-
Notifications
You must be signed in to change notification settings - Fork 1
32 lines (28 loc) · 939 Bytes
/
Copy pathscriptanalyzer.yml
File metadata and controls
32 lines (28 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: ScriptAnalyzer
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
jobs:
analyze:
name: Run PSScriptAnalyzer
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run PSScriptAnalyzer
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -Scope CurrentUser -Force
$settings = Join-Path $PWD 'PSScriptAnalyzerSettings.psd1'
$params = @{ Path = '.'; Recurse = $true; ReportSummary = $true }
if (Test-Path $settings) { $params.Settings = $settings }
$results = Invoke-ScriptAnalyzer @params
$results | Format-Table -AutoSize
if ($results | Where-Object Severity -in 'Error', 'Warning') {
Write-Error "PSScriptAnalyzer found $($results.Count) issue(s)."
exit 1
}