Skip to content

Commit 060a6cc

Browse files
Create main.yml
1 parent b7b90b0 commit 060a6cc

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
}

0 commit comments

Comments
 (0)