-
Notifications
You must be signed in to change notification settings - Fork 1
37 lines (29 loc) · 995 Bytes
/
validate.yml
File metadata and controls
37 lines (29 loc) · 995 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
33
34
35
36
37
name: PowerShell Syntax & Lint Check
on:
push:
paths:
- '**/*.ps1'
pull_request:
paths:
- '**/*.ps1'
jobs:
lint-with-PSScriptAnalyzer:
name: Install and run PSScriptAnalyzer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install PSScriptAnalyzer module
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -ErrorAction Stop
- name: Lint with PSScriptAnalyzer
shell: pwsh
run: |
$issues = Invoke-ScriptAnalyzer -Path . -Recurse
$errors = $issues | Where-Object { $_.Severity -eq 'Error' }
$warnings = $issues | Where-Object { $_.Severity -eq 'Warning' }
Write-Output "PSScriptAnalyzer found $($errors.Count) errors and $($warnings.Count) warnings."
if ($errors.Count -gt 0) {
Write-Error "Failing due to PowerShell linting errors."
}