Skip to content

CICD

CICD #30

Workflow file for this run

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 {
$path = Join-Path ([System.IO.Path]::GetTempPath()) "BcContainerHelper"
New-Item -path $path -itemType Directory | Out-Null
Copy-Item -path (Join-Path $ENV:GITHUB_WORKSPACE "*") -Destination $path -Recurse -Force
Remove-Item -Path (Join-Path $path "Tests") -Force -Recurse
Remove-Item -Path (Join-Path $path ".github") -Force -Recurse
Remove-Item -Path (Join-Path $path ".git") -Force -Recurse
Remove-Item -Path (Join-Path $path ".gitignore") -Force
Remove-Item -Path (Join-Path $path "README.md") -Force
$version = (Get-Content -Path (Join-Path $path 'Version.txt')).split('-')[0]
$prerelease = "preview$(620+$ENV:GITHUB_RUN_NUMBER)"
Set-Content -Path (Join-Path $path 'Version.txt') -value "$version-$prerelease"
Write-Host "BcContainerHelper version $Version$prerelease"
$modulePath = Join-Path $ENV:GITHUB_WORKSPACE "BcContainerHelper.psm1"
Import-Module $modulePath -DisableNameChecking
$functionsToExport = (get-module -Name BcContainerHelper).ExportedFunctions.Keys | Sort-Object
$aliasesToExport = (get-module -Name BcContainerHelper).ExportedAliases.Keys | Sort-Object
$releaseNotes = Get-Content -Path (Join-Path $path "ReleaseNotes.txt")
$idx = $releaseNotes.IndexOf($version)
if ($idx -lt 0) {
throw 'No release notes identified'
}
$versionReleaseNotes = @()
while ($releaseNotes[$idx]) {
$versionReleaseNotes += $releaseNotes[$idx]
$idx++
}
Write-Host "Upload to storage (preview)"
$storageContext = New-AzStorageContext -StorageAccountName 'bcprivate' -UseConnectedAccount
New-AzStorageContainer -Name 'testcontainerhelper' -Context $storageContext -Permission 'Container' -ErrorAction SilentlyContinue | Out-Null
Compress-Archive -path $path -DestinationPath "$($path).zip"
Set-AzStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'testcontainerhelper' -Blob "$version-$prerelease.zip" -Force | Out-Null
Set-AzStorageBlobContent -File "$($path).zip" -Context $storageContext -Container 'testcontainerhelper' -Blob "preview.zip" -Force | Out-Null
}
catch {
Write-Host "::Error::Error publishing module. Error was $($_.Exception.Message)"
$host.SetShouldExit(1)
}