Skip to content

Commit

Permalink
[CI Environment] Enabled the usage of both the old published module n…
Browse files Browse the repository at this point in the history
…ame, as well as the new PBR-aligned (#3892)

* Simplified specs resource type identification

* Updated tempalte spec name handling

* Added a switch to control the name used for publishing via the settings.yml

* Temp switching setting to use classic name for testing

* Removed apparently redundant function

* Introduced temp change

* Introduced temp change

* Added conversion

* Added Microsoft to MS rename for template specs

* Disabled anything but publishing for testing

* Disabled anything but publishing for testing

* Disabled universal packaging as already tested

* Disabled api aligned

* Disabled most of gh pipeline for testing

* Refactored bool conversion to be more robust

* Added missing quote

* Update to latest

* Undid temp change

* Small fix

* Removed temp changes

* Added missing flag

* Added missing flag

* Re-enabled tests

* Readme fixes

* Readme fixes

* Readme fixes

* ReadMe Fixes
  • Loading branch information
AlexanderSehr authored Sep 2, 2023
1 parent 2cdeb1c commit 40ab04c
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 146 deletions.
46 changes: 27 additions & 19 deletions .azuredevops/pipelineTemplates/jobs.publishModule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
## | vmImage | '$(vmImage)' | You can provide either a [poolname] or [vmImage] to run the job on | 'ubuntu20.04' |
## | defaultJobTimeoutInMinutes | 120 | The timeout for the job in this pipeline | 120 |
## | modulePath | '$(modulePath)' | The path to the module to deploy. E.g. [c:/KeyVault] | 'c:/KeyVault' |
## | publishLatest | '$(publishLatest)' | Flag to indicate whether or not to publish a "latest" version to Bicep Registry and Template Specs | true |
## | publishLatest | '$(publishLatest)' | Flag to indicate whether or not to publish a "latest" version to Bicep Registry and Template Specs | true |
## | useApiSpecsAlignedName | '$(useApiSpecsAlignedName)' | Flag to indicate whether or not to publish module using their REST API, or their folder path name | true |
## | templateSpecsRGName | '$(templateSpecsRGName)' | Required to publish to template spec. ResourceGroup of the template spec to publish to | 'mgmt-rg' |
## | templateSpecsRGLocation | '$(templateSpecsRGLocation)' | Required to publish to template spec. Location of the template spec resource group | 'West Europe' |
## | templateSpecsDescription | '$(templateSpecsDescription)' | Required to publish to template spec. Description of the template spec to publish to | 'IaCs module' |
Expand Down Expand Up @@ -60,6 +61,7 @@ parameters:

# Shared
publishLatest: '$(publishLatest)'
useApiSpecsAlignedName: '$(useApiSpecsAlignedName)'

## TemplateSpec-related
templateSpecsDoPublish: '$(templateSpecsDoPublish)'
Expand Down Expand Up @@ -164,10 +166,11 @@ jobs:
#############################
# Add all modules that don't exist in the target location
$missingInputObject = @{
TemplateFilePath = $TemplateFilePath
VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}'
VstsFeedProject = '${{ parameters.vstsFeedProject }}'
VstsFeedName = '${{ parameters.vstsFeedName }}'
TemplateFilePath = $TemplateFilePath
VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}'
VstsFeedProject = '${{ parameters.vstsFeedProject }}'
VstsFeedName = '${{ parameters.vstsFeedName }}'
UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}')
}
Write-Verbose "Invoke Get-ModulesMissingFromUniversalArtifactsFeed with" -Verbose
Expand All @@ -189,11 +192,12 @@ jobs:
Write-Host "##[group]$(' - [{0}] [{1}]' -f $RelPath, $moduleToPublish.Version)"
$functionInput = @{
TemplateFilePath = $moduleToPublish.TemplateFilePath
VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}'
VstsFeedProject = '${{ parameters.vstsFeedProject }}'
VstsFeedName = '${{ parameters.vstsFeedName }}'
ModuleVersion = $moduleToPublish.Version
TemplateFilePath = $moduleToPublish.TemplateFilePath
VstsOrganizationUri = '${{ parameters.vstsOrganizationUri }}'
VstsFeedProject = '${{ parameters.vstsFeedProject }}'
VstsFeedName = '${{ parameters.vstsFeedName }}'
ModuleVersion = $moduleToPublish.Version
UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}')
}
Write-Verbose "Invoke Publish-ModuleToUniversalArtifactsFeed with" -Verbose
Expand Down Expand Up @@ -241,7 +245,7 @@ jobs:
################################
$functionInput = @{
TemplateFilePath = $TemplateFilePath
PublishLatest = [bool] '${{ parameters.publishLatest }}'
PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}')
}
Write-Verbose "Invoke Get-ModulesToPublish with" -Verbose
Expand All @@ -258,9 +262,10 @@ jobs:
# Add all modules that don't exist in the target location
$missingInputObject = @{
TemplateFilePath = $TemplateFilePath
TemplateSpecsRGName = '${{ parameters.templateSpecsRgName }}'
PublishLatest = [bool] '${{ parameters.bicepRegistryRgName }}'
TemplateFilePath = $TemplateFilePath
TemplateSpecsRGName = '${{ parameters.templateSpecsRgName }}'
PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}')
UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}')
}
Write-Verbose "Invoke Get-ModulesMissingFromTemplateSpecsRG with" -Verbose
Expand All @@ -287,6 +292,7 @@ jobs:
TemplateSpecsRgLocation = '${{ parameters.templateSpecsRgLocation }}'
TemplateSpecsDescription = '${{ parameters.templateSpecsDescription }}'
ModuleVersion = $moduleToPublish.Version
UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}')
}
Write-Verbose "Invoke Publish-ModuleToTemplateSpecsRG with" -Verbose
Expand Down Expand Up @@ -336,7 +342,7 @@ jobs:
################################
$functionInput = @{
TemplateFilePath = $TemplateFilePath
PublishLatest = [bool] '${{ parameters.publishLatest }}'
PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}')
}
Write-Verbose "Invoke Get-ModulesToPublish with" -Verbose
Expand All @@ -352,10 +358,11 @@ jobs:
#############################
# Add all modules that don't exist in the target location
$missingInputObject = @{
TemplateFilePath = $TemplateFilePath
BicepRegistryName = '${{ parameters.bicepRegistryName }}'
BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}'
PublishLatest = [bool] '${{ parameters.bicepRegistryRgName }}'
TemplateFilePath = $TemplateFilePath
BicepRegistryName = '${{ parameters.bicepRegistryName }}'
BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}'
PublishLatest = [System.Convert]::ToBoolean('${{ parameters.publishLatest }}')
UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}')
}
Write-Verbose "Invoke Get-ModulesMissingFromPrivateBicepRegistry with" -Verbose
Expand All @@ -382,6 +389,7 @@ jobs:
BicepRegistryRgName = '${{ parameters.bicepRegistryRgName }}'
BicepRegistryRgLocation = '${{ parameters.bicepRegistryRgLocation }}'
ModuleVersion = $moduleToPublish.Version
UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ parameters.useApiSpecsAlignedName }}')
}
Write-Verbose "Invoke Publish-ModuleToPrivateBicepRegistry with" -Verbose
Expand Down
45 changes: 26 additions & 19 deletions .github/actions/templates/publishModule/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@
## ACTION PARAMETERS ##
##-------------------------------------------##
##
## |===========================================================================================================================================================================================================|
## | Parameter | Required | Default | Description | Example |
## |--------------------------|----------|---------|--------------------------------------------------------------------------------------------------|--------------------------------------------------------|
## | templateFilePath | true | '' | The path to the template file to publish | 'modules/api-management/service/main.bicep' |
## | subscriptionId | false | '' | The ID of the subscription to publish to | '11111111-1111-1111-1111-111111111111' |
## | templateSpecsRgName | false | '' | Required to publish to template spec. ResourceGroup of the template spec to publish to | 'artifacts-rg' |
## | templateSpecsRgLocation | false | '' | Required to publish to template spec. Location of the template spec resource group | 'WestEurope' |
## | templateSpecsDescription | false | '' | Required to publish to template spec. Description of the template spec to publish to | 'This is an API-Management service template' |
## | templateSpecsDoPublish | false | 'false' | Flag to indicate whether or not to publish to template specs | 'true' |
## | bicepRegistryName | false | '' | Required to publish to private bicep registry. Name of the container registry to publish to | 'myacr' |
## | bicepRegistryRgName | false | '' | Required to publish to private bicep registry. Name of the container registry resource group | 'artifacts-rg' |
## | bicepRegistryRgLocation | false | '' | Required to publish to private bicep registry. Location of the container registry resource group | 'WestEurope' |
## | bicepRegistryDoPublish | false | 'false' | Flag to indicate whether or not to publish to the private bicep registry | 'true' |
## | publishLatest | false | 'true' | Flag to indicate whether or not to publish a "latest" version | 'true' |
## |===========================================================================================================================================================================================================|
## |==============================================================================================================================================================================================================|
## | Parameter | Required | Default | Description | Example |
## |----------------------------|----------|---------|---------------------------------------------------------------------------------------------------|--------------------------------------------------------|
## | templateFilePath | true | '' | The path to the template file to publish | 'modules/api-management/service/main.bicep' |
## | subscriptionId | false | '' | The ID of the subscription to publish to | '11111111-1111-1111-1111-111111111111' |
## | templateSpecsRgName | false | '' | Required to publish to template spec. ResourceGroup of the template spec to publish to | 'artifacts-rg' |
## | templateSpecsRgLocation | false | '' | Required to publish to template spec. Location of the template spec resource group | 'WestEurope' |
## | templateSpecsDescription | false | '' | Required to publish to template spec. Description of the template spec to publish to | 'This is an API-Management service template' |
## | templateSpecsDoPublish | false | 'false' | Flag to indicate whether or not to publish to template specs | 'true' |
## | bicepRegistryName | false | '' | Required to publish to private bicep registry. Name of the container registry to publish to | 'myacr' |
## | bicepRegistryRgName | false | '' | Required to publish to private bicep registry. Name of the container registry resource group | 'artifacts-rg' |
## | bicepRegistryRgLocation | false | '' | Required to publish to private bicep registry. Location of the container registry resource group | 'WestEurope' |
## | bicepRegistryDoPublish | false | 'false' | Flag to indicate whether or not to publish to the private bicep registry | 'true' |
## | publishLatest | false | 'true' | Flag to indicate whether or not to publish a "latest" version | 'true' |
## | useApiSpecsAlignedName | false | 'false' | Flag to indicate whether or not to publish module using their REST API, or their folder path name | 'true' |
## |==============================================================================================================================================================================================================|
##
##---------------------------------------------##
name: 'Publishing'
Expand Down Expand Up @@ -69,6 +70,10 @@ inputs:
description: 'Flag to indicate whether or not to publish a "latest" version'
default: 'true'
required: false
useApiSpecsAlignedName:
description: 'Flag to indicate whether or not to publish module using their REST API, or their folder path name'
default: 'false'
required: false

runs:
using: 'composite'
Expand Down Expand Up @@ -105,7 +110,7 @@ runs:
################################
$functionInput = @{
TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE "${{ inputs.templateFilePath }}"
PublishLatest = [bool] "${{ inputs.publishLatest }}"
PublishLatest = [System.Convert]::ToBoolean("${{ inputs.publishLatest }}")
}
Write-Verbose "Invoke task with" -Verbose
Expand All @@ -122,7 +127,7 @@ runs:
$missingInputObject = @{
TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE "${{ inputs.templateFilePath }}"
TemplateSpecsRGName = '${{ inputs.templateSpecsRgName }}'
PublishLatest = [bool] "${{ inputs.publishLatest }}"
PublishLatest = [System.Convert]::ToBoolean("${{ inputs.publishLatest }}")
}
Write-Verbose "Invoke Get-ModulesMissingFromTemplateSpecsRG with" -Verbose
Expand All @@ -149,6 +154,7 @@ runs:
TemplateSpecsRgLocation = '${{ inputs.templateSpecsRgLocation }}'
TemplateSpecsDescription = '${{ inputs.templateSpecsDescription }}'
ModuleVersion = $moduleToPublish.Version
UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ inputs.useApiSpecsAlignedName }}')
}
Write-Verbose "Invoke task with" -Verbose
Expand Down Expand Up @@ -185,7 +191,7 @@ runs:
################################
$functionInput = @{
TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE "${{ inputs.templateFilePath }}"
PublishLatest = [bool] "${{ inputs.publishLatest }}"
PublishLatest = [System.Convert]::ToBoolean("${{ inputs.publishLatest }}")
}
Write-Verbose "Invoke task with" -Verbose
Expand All @@ -202,7 +208,7 @@ runs:
TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE "${{ inputs.templateFilePath }}"
BicepRegistryName = '${{ inputs.bicepRegistryName }}'
BicepRegistryRgName = '${{ inputs.bicepRegistryRgName }}'
PublishLatest = [bool] "${{ inputs.publishLatest }}"
PublishLatest = [System.Convert]::ToBoolean("${{ inputs.publishLatest }}")
}
Write-Verbose "Invoke Get-ModulesMissingFromPrivateBicepRegistry with" -Verbose
Expand All @@ -229,6 +235,7 @@ runs:
BicepRegistryRgName = '${{ inputs.bicepRegistryRgName }}'
BicepRegistryRgLocation = '${{ inputs.bicepRegistryRgLocation }}'
ModuleVersion = $moduleToPublish.Version
UseApiSpecsAlignedName = [System.Convert]::ToBoolean('${{ inputs.useApiSpecsAlignedName }}')
}
Write-Verbose "Invoke task with" -Verbose
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/template.module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,4 @@ jobs:
bicepRegistryRgLocation: '${{ env.bicepRegistryRgLocation }}'
bicepRegistryDoPublish: '${{ env.bicepRegistryDoPublish }}'
publishLatest: '${{ env.publishLatest }}'
useApiSpecsAlignedName: '${{ env.useApiSpecsAlignedName }}'
1 change: 1 addition & 0 deletions settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ variables:
# --------------- #

publishLatest: true # [Only for Template-Specs & Bicep Registry] Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments
useApiSpecsAlignedName: false # Publish a module not using its folder path, but the matching name in the REST API (i.e., the classic naming). For example: `bicep/modules/microsoft.keyvault.vaults.secrets` instead of `bicep/modules/key-vault.vault.secret`

# Template-Spec settings #
# ---------------------- #
Expand Down
Loading

0 comments on commit 40ab04c

Please sign in to comment.