Skip to content

Commit

Permalink
Publish new stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusStorhaug committed Dec 5, 2021
1 parent bb5704f commit 033916c
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 105 deletions.
7 changes: 4 additions & 3 deletions .github/actions/templates/publishModule/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ runs:
ModuleVersion = $UpdatedModule.Version
}
Write-Verbose "Invoke task with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
Write-Verbose "Invoke task with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
Publish-ModuleToPrivateBicepRegistry @functionInput -Verbose
Publish-ModuleToPrivateBicepRegistry @functionInput -Verbose
}
} else {
Write-Output "Pipeline is configured to not publish to TemplateSpecs"
}
164 changes: 82 additions & 82 deletions .github/workflows/ms.storage.storageaccounts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
required: false
default: 'true'
push:
branches:
- main
#branches:
# - main
paths:
- '.github/actions/templates/**'
- '.github/workflows/ms.storage.storageaccounts.yml'
Expand Down Expand Up @@ -53,85 +53,85 @@ jobs:
##################
# Global tests
# ------------
job_tests_module_global:
runs-on: ubuntu-20.04
name: 'Run global module tests'
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: 'Test module'
uses: ./.github/actions/templates/validateModuleGeneral
with:
modulePath: '${{ env.modulePath }}'

# Global API tests
# ----------------
job_tests_module_global_api:
runs-on: ubuntu-20.04
name: 'Run global API module tests'
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: 'Test module'
uses: ./.github/actions/templates/validateModuleApis
with:
modulePath: '${{ env.modulePath }}'

###########################
# Deployment module tests #
###########################
job_module_deploy_validation:
runs-on: ubuntu-20.04
name: 'Run deployment validation module tests'
needs:
- job_set_workflow_param
- job_tests_module_global
- job_tests_module_global_api
strategy:
fail-fast: false
matrix:
parameterFilePaths:
['parameters.json', 'min.parameters.json', 'v1.parameters.json']
steps:
- name: 'Checkout'
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set environment variables
uses: deep-mm/set-variables@v1.0
with:
# Name of variable file
variableFileName: 'variables.module' # Don't write .json here
# ----------- #
## Dry Run ##
# ----------- #
- name: 'Test module with parameter file [${{ matrix.parameterFilePaths }}]'
uses: ./.github/actions/templates/validateModuleDeploy
with:
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
parameterFilePath: '${{ env.modulePath }}/.parameters/${{ matrix.parameterFilePaths }}'
location: '${{ env.defaultLocation }}'
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
# ------------------- #
## Deploy & Remove ##
# ------------------- #
- name: 'Deploy module with parameter file [${{ matrix.parameterFilePaths }}]'
id: step_deploy
uses: ./.github/actions/templates/deployModule
with:
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
parameterFilePath: '${{ env.modulePath }}/.parameters/${{ matrix.parameterFilePaths }}'
location: '${{ env.defaultLocation }}'
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ needs.job_set_workflow_param.outputs.removeDeployment }}'
# job_tests_module_global:
# runs-on: ubuntu-20.04
# name: 'Run global module tests'
# steps:
# - name: 'Checkout'
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: 'Test module'
# uses: ./.github/actions/templates/validateModuleGeneral
# with:
# modulePath: '${{ env.modulePath }}'
#
# # Global API tests
# # ----------------
# job_tests_module_global_api:
# runs-on: ubuntu-20.04
# name: 'Run global API module tests'
# steps:
# - name: 'Checkout'
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: 'Test module'
# uses: ./.github/actions/templates/validateModuleApis
# with:
# modulePath: '${{ env.modulePath }}'
#
# ###########################
# # Deployment module tests #
# ###########################
# job_module_deploy_validation:
# runs-on: ubuntu-20.04
# name: 'Run deployment validation module tests'
# needs:
# - job_set_workflow_param
# - job_tests_module_global
# - job_tests_module_global_api
# strategy:
# fail-fast: false
# matrix:
# parameterFilePaths:
# ['parameters.json', 'min.parameters.json', 'v1.parameters.json']
# steps:
# - name: 'Checkout'
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Set environment variables
# uses: deep-mm/set-variables@v1.0
# with:
# # Name of variable file
# variableFileName: 'variables.module' # Don't write .json here
# # ----------- #
# ## Dry Run ##
# # ----------- #
# - name: 'Test module with parameter file [${{ matrix.parameterFilePaths }}]'
# uses: ./.github/actions/templates/validateModuleDeploy
# with:
# templateFilePath: '${{ env.modulePath }}/deploy.bicep'
# parameterFilePath: '${{ env.modulePath }}/.parameters/${{ matrix.parameterFilePaths }}'
# location: '${{ env.defaultLocation }}'
# resourceGroupName: '${{ env.resourceGroupName }}'
# subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
# managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
# # ------------------- #
# ## Deploy & Remove ##
# # ------------------- #
# - name: 'Deploy module with parameter file [${{ matrix.parameterFilePaths }}]'
# id: step_deploy
# uses: ./.github/actions/templates/deployModule
# with:
# templateFilePath: '${{ env.modulePath }}/deploy.bicep'
# parameterFilePath: '${{ env.modulePath }}/.parameters/${{ matrix.parameterFilePaths }}'
# location: '${{ env.defaultLocation }}'
# resourceGroupName: '${{ env.resourceGroupName }}'
# subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
# managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
# removeDeployment: '${{ needs.job_set_workflow_param.outputs.removeDeployment }}'

###############
# PUBLISH #
Expand All @@ -142,7 +142,7 @@ jobs:
runs-on: ubuntu-20.04
needs:
- job_set_workflow_param
- job_module_deploy_validation
#- job_module_deploy_validation
steps:
- name: 'Checkout'
uses: actions/checkout@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ module pid_cuaId '.bicep/nested_cuaId.bicep' = if (!empty(cuaId)) {
params: {}
}


resource storageAccount 'Microsoft.Storage/storageAccounts@2021-06-01' existing = {
name: storageAccountName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2021-06-01' existing
}
}


resource table 'Microsoft.Storage/storageAccounts/tableServices/tables@2021-06-01' = {
name: name
parent: storageAccount::tableServices
Expand Down
22 changes: 12 additions & 10 deletions utilities/pipelines/resourcePublish/Get-ModifiedModules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,15 @@ function Get-NewModuleVersion {
)
$Version = Get-ModuleVersion -ModuleFilePath $ModuleFilePath
$Patch = Get-GitDistance
$NewVersion = "$Version.$Patch"

$CurrentBranch = git branch --show-current
if ($CurrentBranch -ne 'main') {
$Patch = "$Patch-$CurrentBranch".Replace('\','').Replace('/','')
$PreRelease = $CurrentBranch -replace '[^a-zA-Z0-9\.\-_]'
$NewVersion = "$NewVersion-$PreRelease"
}
$NewVersion = [System.Version]"$Version.$Patch"
return $NewVersion.ToString()

return $NewVersion
}

function Get-ModifiedModules {
Expand All @@ -158,24 +161,23 @@ function Get-ModifiedModules {
Version = $ModuleVersion
ModulePath = $_.FullName
}
Write-Output "Update: $ModuleName - $ModuleVersion"
Write-Verbose "Update: $ModuleName - $ModuleVersion"

Write-Output 'Checking for parent modules'
$ParentModuleFiles = Get-ParentModule -ModuleFilePath $_ -Recurse
Write-Output "Checking for parent modules - Found $($ParentModuleFiles.Count)"
$ParentModuleFiles
Write-Verbose 'Checking for parent modules'
$ParentModuleFiles = Get-ParentModule -ModuleFilePath $_.FullName -Recurse
Write-Verbose "Checking for parent modules - Found $($ParentModuleFiles.Count)"
$ParentModuleFiles | ForEach-Object {
$ParentModuleVersion = Get-NewModuleVersion -ModuleFilePath $_.FullName

$ModulesToUpdate += [pscustomobject]@{
Version = $ParentModuleVersion
ModulePath = $_.FullName
}
Write-Output "Update parent: $ParentModuleName - $ParentModuleVersion"
Write-Verbose "Update parent: $($_.FullName) - $ParentModuleVersion"
}
}

$ModulesToUpdate = $ModulesToUpdate | Sort-Object Name -Descending -Unique
$ModulesToUpdate = $ModulesToUpdate | Sort-Object ModulePath -Descending -Unique

return $ModulesToUpdate
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ function Publish-ModuleToPrivateBicepRegistry {
}
}

# Extracts Microsoft.KeyVault/vaults from e.g. C:\arm\Microsoft.KeyVault\vaults\deploy.bicep
$moduleIdentifier = (Split-Path $templateFilePath -Parent).Replace('\', '/').Split('/arm/')[1]
$moduleRegistryIdentifier = 'bicep/modules/{0}' -f $moduleIdentifier.Replace('\', '/').Replace('/', '.').ToLower()

#############################################
## Publish to private bicep registry ##
#############################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ function Publish-ModuleToTemplateSpec {
[Parameter(Mandatory)]
[string] $TemplateSpecsDescription,

[Parameter(Mandatory = $false)]
[string] $customVersion = '0.0.1',

[Parameter(Mandatory = $false)]
[ValidateSet('Major', 'Minor', 'Patch')]
[string] $versioningOption = 'Patch'
[Parameter(Mandatory)]
[string] $ModuleVersion
)

begin {
Expand All @@ -70,11 +66,11 @@ function Publish-ModuleToTemplateSpec {
################################
## Create template spec ##
################################
if ($PSCmdlet.ShouldProcess("Template spec [$templateSpecIdentifier] version [$newVersion]", 'Publish')) {
if ($PSCmdlet.ShouldProcess("Template spec [$templateSpecIdentifier] version [$ModuleVersion]", 'Publish')) {
$templateSpecInputObject = @{
ResourceGroupName = $TemplateSpecsRgName
Name = $templateSpecIdentifier
Version = $newVersion
Version = $ModuleVersion
Description = $TemplateSpecsDescription
Location = $templateSpecsRgLocation
TemplateFile = $TemplateFilePath
Expand Down

0 comments on commit 033916c

Please # to comment.