-
Notifications
You must be signed in to change notification settings - Fork 3
44 lines (39 loc) · 1.3 KB
/
Copy pathci.yml
File metadata and controls
44 lines (39 loc) · 1.3 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
44
name: CI
permissions:
contents: read
on:
push:
branches: [ 📦Current ]
pull_request:
branches: [ 📦Current ]
jobs:
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Check PowerShell Version
shell: pwsh
run: |
$PSVersion = $PSVersionTable.PSVersion
Write-Host "PowerShell Version: $PSVersion"
if ($PSVersion -lt [Version]"5.1") {
throw "PowerShell version must be 5.1 or higher"
}
- name: Test Script Syntax
shell: pwsh
run: |
$scripts = Get-ChildItem -Path . -Filter *.ps1 -Recurse
foreach ($script in $scripts) {
$errors = $null
$null = [System.Management.Automation.PSParser]::Tokenize((Get-Content $script.FullName -Raw), [ref]$errors)
if ($errors.Count -gt 0) {
throw "Syntax errors found in $($script.FullName): $($errors | ConvertTo-Json)"
}
}
- name: Check for Admin Rights
shell: pwsh
run: |
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "Running without admin rights (expected in CI environment)"
}