-
Notifications
You must be signed in to change notification settings - Fork 2
42 lines (37 loc) · 1.21 KB
/
Copy pathvalidate-powershell.yml
File metadata and controls
42 lines (37 loc) · 1.21 KB
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
33
34
35
36
37
38
39
40
41
42
name: Validate PowerShell
on:
push:
paths:
- '**/*.ps1'
- 'PSScriptAnalyzerSettings.psd1'
- '.github/workflows/validate-powershell.yml'
pull_request:
paths:
- '**/*.ps1'
- 'PSScriptAnalyzerSettings.psd1'
- '.github/workflows/validate-powershell.yml'
jobs:
lint:
name: PSScriptAnalyzer
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
if (-not (Get-Module -ListAvailable -Name PSScriptAnalyzer)) {
Install-Module -Name PSScriptAnalyzer -Force -SkipPublisherCheck -Scope CurrentUser
}
Import-Module PSScriptAnalyzer
- name: Run PSScriptAnalyzer on all PowerShell scripts
shell: pwsh
run: |
$results = Invoke-ScriptAnalyzer -Path . -Recurse -Settings PSScriptAnalyzerSettings.psd1
if ($results) {
$results | Format-Table -AutoSize
Write-Error "PSScriptAnalyzer found $($results.Count) issue(s). Please fix them before merging."
exit 1
}
Write-Host "PSScriptAnalyzer: No issues found." -ForegroundColor Green