Skip to content

Sa 3607 gha ci workflow km #93

Sa 3607 gha ci workflow km

Sa 3607 gha ci workflow km #93

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 checkout origin $GITHUB_BASE_REF
$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++
}
}
# 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
}
# 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