forked from Light-Heart-Labs/DreamServer
-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (39 loc) · 1.2 KB
/
lint-powershell.yml
File metadata and controls
43 lines (39 loc) · 1.2 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
43
name: Lint PowerShell
on:
pull_request:
push:
branches:
- main
- master
jobs:
powershell-lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: dream-server
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PSScriptAnalyzer
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module PSScriptAnalyzer -Force -Scope CurrentUser
- name: Run PowerShell Script Analyzer
shell: pwsh
run: |
$scripts = Get-ChildItem -Path installers -Filter *.ps1 -Recurse
if (-not $scripts) {
Write-Host "No PowerShell scripts found."
exit 0
}
$failed = $false
foreach ($script in $scripts) {
Write-Host "Analyzing $($script.FullName)"
$results = Invoke-ScriptAnalyzer -Path $script.FullName -Settings ./PSScriptAnalyzerSettings.psd1 -Severity Error,Warning
if ($results) {
$results | Format-Table RuleName, Severity, Message, ScriptName, Line -AutoSize
$failed = $true
}
}
if ($failed) { exit 1 }