Skip to content

Update Set-CippKeyVaultSecret.ps1 #16

Update Set-CippKeyVaultSecret.ps1

Update Set-CippKeyVaultSecret.ps1 #16

# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy Powershell project to Azure Function App - cipp2zyk4
on:
push:
branches:
- kv-replacement-test
workflow_dispatch:
env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
jobs:
deploy:
runs-on: windows-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
- name: Setup PowerShell module cache
id: cacher
uses: actions/cache@v3
with:
path: "~/.local/share/powershell/Modules"
key: ${{ runner.os }}-ModuleBuilder
- name: Install ModuleBuilder
if: steps.cacher.outputs.cache-hit != 'true'
shell: pwsh
run: |
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module ModuleBuilder -AllowClobber -Force
- name: Build CIPPCore Module
shell: pwsh
run: |
$ModulePath = Join-Path $env:GITHUB_WORKSPACE "Modules/CIPPCore"
$OutputPath = Join-Path $env:GITHUB_WORKSPACE "Output"
Write-Host "Building module from: $ModulePath"
Write-Host "Output directory: $OutputPath"
# Build the module using ModuleBuilder
Build-Module -SourcePath $ModulePath -OutputDirectory $OutputPath -Verbose
# Replace the source module with the built module
Remove-Item -Path $ModulePath -Recurse -Force
Copy-Item -Path (Join-Path $OutputPath "CIPPCore") -Destination $ModulePath -Recurse -Force
Write-Host "Module built and replaced successfully"
# Clean up output directory
Remove-Item -Path $OutputPath -Recurse -Force
- name: Build CippExtensions Module
shell: pwsh
run: |
$ModulePath = Join-Path $env:GITHUB_WORKSPACE "Modules/CippExtensions"
$OutputPath = Join-Path $env:GITHUB_WORKSPACE "Output"
Write-Host "Building module from: $ModulePath"
Write-Host "Output directory: $OutputPath"
# Build the module using ModuleBuilder
Build-Module -SourcePath $ModulePath -OutputDirectory $OutputPath -Verbose
# Replace the source module with the built module
Remove-Item -Path $ModulePath -Recurse -Force
Copy-Item -Path (Join-Path $OutputPath "CippExtensions") -Destination $ModulePath -Recurse -Force
Write-Host "Module built and replaced successfully"
# Clean up output directory
Remove-Item -Path $OutputPath -Recurse -Force
- name: Prepare deployment package
shell: pwsh
run: |
Write-Host "=== Cleaning deployment package ==="
# Remove .git folder and other unnecessary files
Remove-Item -Recurse -Force .git -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force .github -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force .vscode -ErrorAction SilentlyContinue
Remove-Item -Force .gitignore -ErrorAction SilentlyContinue
Remove-Item -Force .gitattributes -ErrorAction SilentlyContinue
Remove-Item -Force *.md -ErrorAction SilentlyContinue
# Show final package size
$size = (Get-ChildItem -Recurse -File | Measure-Object -Property Length -Sum).Sum / 1MB
Write-Host "`nFinal package size: $([math]::Round($size, 2)) MB"
- name: Analyze package contents
shell: pwsh
run: |
Write-Host "=== Top 20 largest files ==="
Get-ChildItem -Recurse -File |
Sort-Object Length -Descending |
Select-Object -First 20 |
Format-Table @{L='Size (MB)';E={[math]::Round($_.Length/1MB, 2)}}, FullName -AutoSize
Write-Host "`n=== Size by directory ==="
Get-ChildItem -Directory | ForEach-Object {
$size = (Get-ChildItem $_.FullName -Recurse -File | Measure-Object -Property Length -Sum).Sum / 1MB
[PSCustomObject]@{
Directory = $_.Name
'Size (MB)' = [math]::Round($size, 2)
}
} | Sort-Object 'Size (MB)' -Descending | Format-Table -AutoSize
Write-Host "`n=== Checking for duplicate modules ==="
Get-ChildItem -Recurse -Directory -Filter "Az.*" | Select-Object FullName
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'cipp2zyk4'
slot-name: 'Production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_0BFD766868004FF487F44F7EC5B19D15 }}