CICD #25
This file contains 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
name: CICD | |
on: | |
workflow_dispatch: | |
push: | |
paths-ignore: | |
- '**.md' | |
- '.github/**' | |
branches: [ master ] | |
permissions: | |
contents: read | |
actions: read | |
pull-requests: write | |
checks: write | |
id-token: write | |
concurrency: | |
group: 'runTests-${{ github.ref }}' | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: powershell | |
jobs: | |
Deploy: | |
runs-on: [ windows-latest ] | |
steps: | |
- name: 'Az CLI login' | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
enable-AzPSSession: true | |
- name: Install Azure Powershell Modules | |
run: | | |
if(-not (Get-Module 'Az.Storage' -ListAvailable)) { | |
Install-Module -Name 'Az.Storage' -Force -AllowClobber | |
} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Deploy | |
run: | | |
try { | |
Write-Host "Upload to storage (preview)" | |
$storageContext = New-AzStorageContext -StorageAccountName 'businesscentralapps' -UseConnectedAccount | |
New-AzStorageContainer -Name 'public' -Context $storageContext -Permission 'Container' -ErrorAction Ignore | Out-Null | |
Compress-Archive -path $path -DestinationPath "$($path).zip" | |
Set-AzStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'public' -Blob "$version-$prerelease.zip" -Force | Out-Null | |
Set-AzStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'public' -Blob "preview.zip" -Force | Out-Null | |
} | |
catch { | |
Write-Host "::Error::Error publishing module. Error was $($_.Exception.Message)" | |
$host.SetShouldExit(1) | |
} |