File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : PowerShell Script Validator
2+
3+ # 1. TRIGGER:
4+ on :
5+ push :
6+ branches : [ "main" ]
7+ pull_request :
8+ branches : [ "main" ]
9+
10+ # 2. JOBS:
11+ jobs :
12+ lint-scripts :
13+ name : Analyze PowerShell Code
14+ # Spin up a fresh Windows virtual machine
15+ runs-on : windows-latest
16+
17+ # 3. STEPS: tasks to execute
18+ steps :
19+ # Step A: Download repo code
20+ - name : Checkout Repository
21+ uses : actions/checkout@v4
22+
23+ # Step B: Run Posh
24+ - name : Run PSScriptAnalyzer
25+ shell : pwsh
26+ run : |
27+ Write-Host "Installing PSScriptAnalyzer..."
28+ Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
29+
30+ Write-Host "Scanning repository for PowerShell scripts..."
31+ $results = Invoke-ScriptAnalyzer -Path . -Recurse
32+
33+ if ($results) {
34+ $results | Format-Table -AutoSize
35+ Write-Error "Syntax issues or best-practice violations found!"
36+ exit 1 # This tells GitHub to mark the pipeline as FAILED
37+ } else {
38+ Write-Host "Success! All scripts look good."
39+ }
You can’t perform that action at this time.
0 commit comments