This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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: '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 }} |