-
Notifications
You must be signed in to change notification settings - Fork 153
68 lines (66 loc) · 2.08 KB
/
powershell-module-ci.yml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: PowerShell Module CI
on:
pull_request:
branches:
- 'JumpCloudModule_**'
jobs:
check-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check Changes in Folder
shell: pwsh
run: |
$list = @("/PowerShell/Deploy/*", "/PowerShell/JumpCloud Module/*", "/PowerShell/ModuleChangelog.md")
# Loop through each file in the list then do git diff
$difCount = 0 # Diff Counter
git fetch origin $env:GITHUB_BASE_RE
$gitDiff = git diff origin/$env:GITHUB_BASE_REF..HEAD
foreach ($path in $list) {
# Check if the path exists in the Git diff
if ($gitDiff -match [regex]::Escape($path)) {
Write-Host "Path found in Git diff: $path"
$difCount++
}
}
$gitdiff
# If difcount = 0 then no changes were made to the files in the list, throw exit 1
if ($difCount -eq 0) {
Write-Host "No changes were made to the files in the list, exiting with code 1"
exit 1
} else {
Write-Host "Changes were made to the files in the list"
exit 0
}
# Create a job to check if recent job has failed then exit all GH Actions
check-failed-job:
runs-on: ubuntu-latest
needs: check-changes
if: ${{ failure() }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Exit with error code
run: exit 1
clone:
needs: check-failed-job
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
Publish-PowerShell-Artifact:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
Source: "CodeArtifact"
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
PowerShell
- shell: pwsh
run: |
. "./PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery