Skip to content

Commit 54fd2bc

Browse files
committed
restore modulebuilder in dev
1 parent b611861 commit 54fd2bc

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

.github/workflows/dev_api.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,60 @@ jobs:
3333
path: "~/.local/share/powershell/Modules"
3434
key: ${{ runner.os }}-ModuleBuilder
3535

36+
- name: Install ModuleBuilder
37+
if: steps.cacher.outputs.cache-hit != 'true'
38+
shell: pwsh
39+
run: |
40+
Set-PSRepository PSGallery -InstallationPolicy Trusted
41+
Install-Module ModuleBuilder -AllowClobber -Force
42+
43+
- name: Build CIPPCore Module
44+
shell: pwsh
45+
run: |
46+
$ModulePath = Join-Path $env:GITHUB_WORKSPACE "Modules/CIPPCore"
47+
$OutputPath = Join-Path $env:GITHUB_WORKSPACE "Output"
48+
49+
Write-Host "Building module from: $ModulePath"
50+
Write-Host "Output directory: $OutputPath"
51+
52+
# Generate function permissions before replacing the source module
53+
$ToolsPath = Join-Path $env:GITHUB_WORKSPACE "Tools"
54+
$ScriptPath = Join-Path $ToolsPath "Build-FunctionPermissions.ps1"
55+
pwsh -File $ScriptPath -ModulePath $ModulePath
56+
57+
# Build the module using ModuleBuilder
58+
Build-Module -SourcePath $ModulePath -OutputDirectory $OutputPath -Verbose
59+
60+
# Replace the source module with the built module
61+
Remove-Item -Path $ModulePath -Recurse -Force
62+
Copy-Item -Path (Join-Path $OutputPath "CIPPCore") -Destination $ModulePath -Recurse -Force
63+
64+
Write-Host "Module built and replaced successfully"
65+
66+
# Clean up output directory
67+
Remove-Item -Path $OutputPath -Recurse -Force
68+
69+
- name: Build CippExtensions Module
70+
shell: pwsh
71+
run: |
72+
$ModulePath = Join-Path $env:GITHUB_WORKSPACE "Modules/CippExtensions"
73+
$OutputPath = Join-Path $env:GITHUB_WORKSPACE "Output"
74+
75+
Write-Host "Building module from: $ModulePath"
76+
Write-Host "Output directory: $OutputPath"
77+
78+
# Build the module using ModuleBuilder
79+
Build-Module -SourcePath $ModulePath -OutputDirectory $OutputPath -Verbose
80+
81+
# Replace the source module with the built module
82+
Remove-Item -Path $ModulePath -Recurse -Force
83+
Copy-Item -Path (Join-Path $OutputPath "CippExtensions") -Destination $ModulePath -Recurse -Force
84+
85+
Write-Host "Module built and replaced successfully"
86+
87+
# Clean up output directory
88+
Remove-Item -Path $OutputPath -Recurse -Force
89+
3690
- name: Login to Azure
3791
uses: azure/login@v2
3892
with:

Tools/Build-FunctionPermissions.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ foreach ($command in $commands | Sort-Object -Property Name | Select-Object -Uni
7070
$functionality = ''
7171
}
7272

73-
if ($role -or $functionality) {
73+
if ($role -and $functionality) {
7474
$permissions[$command.Name] = @{
7575
Role = $role
7676
Functionality = $functionality

0 commit comments

Comments
 (0)