From 1e398a18ec52df80aa8794169bbd487c06d499ec Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 12:46:32 +0200 Subject: [PATCH 01/13] Added ps-rule.yaml --- ps-rule.yaml | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 ps-rule.yaml diff --git a/ps-rule.yaml b/ps-rule.yaml new file mode 100644 index 0000000000..d7ecc15c9d --- /dev/null +++ b/ps-rule.yaml @@ -0,0 +1,57 @@ +# +# PSRule for Azure configuration +# + +# Please see the documentation for all configuration options: +# https://aka.ms/ps-rule/options +# https://aka.ms/ps-rule-azure/options + +# Configure binding for local rules. +binding: + preferTargetInfo: true + targetType: + - type + - resourceType + +# Require minimum versions of modules. +requires: + PSRule: '@pre >=2.4.0' + PSRule.Rules.Azure: '@pre >=1.19.2' + +# Use PSRule for Azure. +include: + module: + - PSRule.Rules.Azure + +output: + culture: + - 'en-US' + +input: + pathIgnore: + + # Ignore other files in the repository. + - '.vscode/' + - '.github/' + - '*.md' + + # Exclude modules but not tests. + - 'modules/**/*.bicep' + - 'modules/**/*.test.bicep' + +configuration: + # Enable automatic expansion of Azure parameter files. + AZURE_PARAMETER_FILE_EXPANSION: true + + # Enable automatic expansion of Azure Bicep source files. + AZURE_BICEP_FILE_EXPANSION: true + + # Configures the number of seconds to wait for build Bicep files. + AZURE_BICEP_FILE_EXPANSION_TIMEOUT: 10 + +# Suppression ignores rules for a specific Azure resource by name. +# suppression: +# Azure.KeyVault.Logs: +# - kvtest001 +# Azure.Storage.BlobPublicAccess: +# - sttest001 From d818ccf0f223a577232a6a4b6a117ca15b7ab6b2 Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 12:56:32 +0200 Subject: [PATCH 02/13] testing psrule --- .github/workflows/ms.resources.resourcegroups.yml | 14 ++++++++++++++ ps-rule.yaml | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index 17916c688f..02cfc478b7 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -81,6 +81,20 @@ jobs: modulePath: '${{ env.modulePath }}' moduleTestFilePath: '${{ env.moduleTestFilePath }}' + job_psrule_test: + name: 'PsRule Analyze repository' + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v3 + + # Run analysis by using the PSRule GitHub action. + - name: Run PSRule analysis + uses: microsoft/ps-rule@v2.4.0 + with: + modules: 'PSRule.Rules.Azure' + inputPath: '../../modules/Microsoft.Resources/resourceGroups/ ############################# # Deployment validation # ############################# diff --git a/ps-rule.yaml b/ps-rule.yaml index d7ecc15c9d..0e744129d9 100644 --- a/ps-rule.yaml +++ b/ps-rule.yaml @@ -37,7 +37,7 @@ input: # Exclude modules but not tests. - 'modules/**/*.bicep' - - 'modules/**/*.test.bicep' + - '!modules/**/*.test.bicep' configuration: # Enable automatic expansion of Azure parameter files. From 9165442a3675c10d70d87d2ea1c65fde5c855b12 Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 12:58:40 +0200 Subject: [PATCH 03/13] fixing typo yml --- .github/workflows/ms.resources.resourcegroups.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index 02cfc478b7..d7bc21dd23 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -92,9 +92,11 @@ jobs: # Run analysis by using the PSRule GitHub action. - name: Run PSRule analysis uses: microsoft/ps-rule@v2.4.0 - with: - modules: 'PSRule.Rules.Azure' - inputPath: '../../modules/Microsoft.Resources/resourceGroups/ + with: + modules: 'PSRule.Rules.Azure' + inputPath: '../../modules/Microsoft.Resources/resourceGroups/' + + ############################# # Deployment validation # ############################# From b30b59b79cc9605a1613422594bc384973403a44 Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 12:59:54 +0200 Subject: [PATCH 04/13] fixed typo --- .github/workflows/ms.resources.resourcegroups.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index d7bc21dd23..e0e57d92a4 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -92,9 +92,9 @@ jobs: # Run analysis by using the PSRule GitHub action. - name: Run PSRule analysis uses: microsoft/ps-rule@v2.4.0 - with: - modules: 'PSRule.Rules.Azure' - inputPath: '../../modules/Microsoft.Resources/resourceGroups/' + with: + modules: 'PSRule.Rules.Azure' + inputPath: '../../modules/Microsoft.Resources/resourceGroups/' ############################# From fed4a9d5c87f671af311ce52d4a39240c489ba7f Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 13:04:31 +0200 Subject: [PATCH 05/13] testing input path --- .github/workflows/ms.resources.resourcegroups.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index e0e57d92a4..df6363e85a 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -94,7 +94,7 @@ jobs: uses: microsoft/ps-rule@v2.4.0 with: modules: 'PSRule.Rules.Azure' - inputPath: '../../modules/Microsoft.Resources/resourceGroups/' + inputPath: 'modules/Microsoft.Resources/resourceGroups/' ############################# From 41c4242e6e53ffe616849f4e729c55e437ad7a3d Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 16:23:53 +0200 Subject: [PATCH 06/13] Added token replacement task --- .../workflows/ms.resources.resourcegroups.yml | 201 +++++++++++++----- 1 file changed, 142 insertions(+), 59 deletions(-) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index df6363e85a..7ba8ecbd5b 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -89,6 +89,89 @@ jobs: - name: Checkout uses: actions/checkout@v3 + # [Token replacement] task(s) + # --------------------------- + - name: 'Replace tokens in template file' + uses: azure/powershell@v1 + with: + azPSVersion: 'latest' + inlineScript: | + $templateFilePath = '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' + $parameterFilePath = "" + $customParameterFileTokens = "" + # Grouping task logs + Write-Output '::group::Replace tokens in template file' + + # Load used functions + . (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'tokensReplacement' 'Convert-TokensInFileList.ps1') + + # Get target files + $targetFileList = @($templateFilePath) + if(-not [String]::IsNullOrEmpty($parameterFilePath)) { + $targetFileList += $parameterFilePath + } + + # Get Service Principal Object ID + $context = Get-AzContext + $servicePrincipalAppId = $context.Account.Id + $servicePrincipal = Get-AzADServicePrincipal -ApplicationId $servicePrincipalAppId + $servicePrincipalObjectId = $servicePrincipal.Id + + # Construct Token Function Input + $ConvertTokensInputs = @{ + FilePathList = $targetFileList + Tokens = @{} + TokenPrefix = '${{ env.tokenPrefix }}' + TokenSuffix = '${{ env.tokenSuffix }}' + } + + # Add enforced tokens + $ConvertTokensInputs.Tokens += @{ + resourceGroupName = '${{ env.resourceGroupName }}' + subscriptionId = '${{ secrets.ARM_SUBSCRIPTION_ID }}' + managementGroupId = '${{ secrets.ARM_MGMTGROUP_ID }}' + tenantId = '${{ env.ARM_TENANT_ID }}' + } + + # Add local (source control) tokens + $tokenMap = @{} + foreach ($token in (Get-ChildItem env: | Where-Object -Property Name -Like "localToken_*")) { + $tokenMap += @{ $token.Name.Replace('localToken_','','OrdinalIgnoreCase') = $token.value } + } + Write-Verbose ('Using local tokens [{0}]' -f ($tokenMap.Keys -join ', ')) -Verbose + $ConvertTokensInputs.Tokens += $tokenMap + + # Swap 'namePrefix' token if empty and provided as a GitHub secret + if([String]::IsNullOrEmpty($ConvertTokensInputs.Tokens['namePrefix'])){ + Write-Verbose 'Using [namePrefix] token from GitHub' -Verbose + $ConvertTokensInputs.Tokens['namePrefix'] = '${{ env.TOKEN_NAMEPREFIX }}' + } + + # Add custom tokens (passed in via the pipeline) + if(-not [String]::IsNullOrEmpty($customParameterFileTokens)) { + $customTokens = $customParameterFileTokens| ConvertFrom-Json -AsHashTable + Write-Verbose ('Using custom parameter file tokens [{0}]' -f ($customTokens.Keys -join ', ')) -Verbose + $ConvertTokensInputs.Tokens += $customTokens + } + + Write-Verbose "Convert Tokens Input:`n $($ConvertTokensInputs | ConvertTo-Json -Depth 10)" -Verbose + + # Invoke Token Replacement Functionality [For Module] + $null = Convert-TokensInFileList @ConvertTokensInputs + + # Get target files for modules dependencies + $DependencyParameterFilePaths = [System.Collections.ArrayList]@() + $DependencyParameterFolders = Get-ChildItem -Path (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'dependencies') -Recurse -Filter 'parameters' -Directory + foreach ($FolderPath in $DependencyParameterFolders.FullName) { + $DependencyParameterFilePaths += Get-ChildItem -Path $FolderPath -Recurse -Filter '*.json' + } + $ConvertTokensInputs.FilePathList = $DependencyParameterFilePaths + + # Invoke Token Replacement Functionality [For Dependencies] + $null = Convert-TokensInFileList @ConvertTokensInputs + + Write-Output '::endgroup::' + # Run analysis by using the PSRule GitHub action. - name: Run PSRule analysis uses: microsoft/ps-rule@v2.4.0 @@ -100,62 +183,62 @@ jobs: ############################# # Deployment validation # ############################# - job_module_deploy_validation: - runs-on: ubuntu-20.04 - name: 'Deployment validation' - needs: - - job_initialize_pipeline - - job_module_pester_validation - strategy: - fail-fast: false - matrix: - moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }} - steps: - - name: 'Checkout' - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set environment variables - uses: ./.github/actions/templates/setEnvironmentVariables - with: - variablesPath: ${{ env.variablesPath }} - - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' - uses: ./.github/actions/templates/validateModuleDeployment - with: - templateFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' - location: '${{ env.location }}' - resourceGroupName: '${{ env.resourceGroupName }}' - subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' - managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' - removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}' - - ################## - # Publishing # - ################## - job_publish_module: - name: 'Publishing' - if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.event.inputs.prerelease == 'true' - runs-on: ubuntu-20.04 - needs: - - job_module_deploy_validation - steps: - - name: 'Checkout' - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set environment variables - uses: ./.github/actions/templates/setEnvironmentVariables - with: - variablesPath: ${{ env.variablesPath }} - - name: 'Publishing' - uses: ./.github/actions/templates/publishModule - with: - templateFilePath: '${{ env.modulePath }}/deploy.bicep' - templateSpecsRGName: '${{ env.templateSpecsRGName }}' - templateSpecsRGLocation: '${{ env.templateSpecsRGLocation }}' - templateSpecsDescription: '${{ env.templateSpecsDescription }}' - templateSpecsDoPublish: '${{ env.templateSpecsDoPublish }}' - bicepRegistryName: '${{ env.bicepRegistryName }}' - bicepRegistryRGName: '${{ env.bicepRegistryRGName }}' - bicepRegistryRgLocation: '${{ env.bicepRegistryRgLocation }}' - bicepRegistryDoPublish: '${{ env.bicepRegistryDoPublish }}' + # job_module_deploy_validation: + # runs-on: ubuntu-20.04 + # name: 'Deployment validation' + # needs: + # - job_initialize_pipeline + # - job_module_pester_validation + # strategy: + # fail-fast: false + # matrix: + # moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }} + # steps: + # - name: 'Checkout' + # uses: actions/checkout@v2 + # with: + # fetch-depth: 0 + # - name: Set environment variables + # uses: ./.github/actions/templates/setEnvironmentVariables + # with: + # variablesPath: ${{ env.variablesPath }} + # - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' + # uses: ./.github/actions/templates/validateModuleDeployment + # with: + # templateFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' + # location: '${{ env.location }}' + # resourceGroupName: '${{ env.resourceGroupName }}' + # subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' + # managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' + # removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}' + + # ################## + # # Publishing # + # ################## + # job_publish_module: + # name: 'Publishing' + # if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.event.inputs.prerelease == 'true' + # runs-on: ubuntu-20.04 + # needs: + # - job_module_deploy_validation + # steps: + # - name: 'Checkout' + # uses: actions/checkout@v2 + # with: + # fetch-depth: 0 + # - name: Set environment variables + # uses: ./.github/actions/templates/setEnvironmentVariables + # with: + # variablesPath: ${{ env.variablesPath }} + # - name: 'Publishing' + # uses: ./.github/actions/templates/publishModule + # with: + # templateFilePath: '${{ env.modulePath }}/deploy.bicep' + # templateSpecsRGName: '${{ env.templateSpecsRGName }}' + # templateSpecsRGLocation: '${{ env.templateSpecsRGLocation }}' + # templateSpecsDescription: '${{ env.templateSpecsDescription }}' + # templateSpecsDoPublish: '${{ env.templateSpecsDoPublish }}' + # bicepRegistryName: '${{ env.bicepRegistryName }}' + # bicepRegistryRGName: '${{ env.bicepRegistryRGName }}' + # bicepRegistryRgLocation: '${{ env.bicepRegistryRgLocation }}' + # bicepRegistryDoPublish: '${{ env.bicepRegistryDoPublish }}' From 966c79456a3578fbe03f7ebeab9351561e4251e9 Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 16:28:34 +0200 Subject: [PATCH 07/13] Adding Azure login task --- .github/workflows/ms.resources.resourcegroups.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index 7ba8ecbd5b..a2e990d9d0 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -89,6 +89,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Azure Login + uses: Azure/login@v1 + with: + creds: ${{ env.AZURE_CREDENTIALS }} + enable-AzPSSession: true + # [Token replacement] task(s) # --------------------------- - name: 'Replace tokens in template file' From 0037e17b190a9a279209e275b81b4a5bda743914 Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 16:30:29 +0200 Subject: [PATCH 08/13] checking context --- .github/workflows/ms.resources.resourcegroups.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index a2e990d9d0..b18df4e10a 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -119,6 +119,7 @@ jobs: # Get Service Principal Object ID $context = Get-AzContext + $context $servicePrincipalAppId = $context.Account.Id $servicePrincipal = Get-AzADServicePrincipal -ApplicationId $servicePrincipalAppId $servicePrincipalObjectId = $servicePrincipal.Id From 36f189ca22415c9a6eb66de7fb91dabee8f68698 Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 16:31:02 +0200 Subject: [PATCH 09/13] adding write-output --- .github/workflows/ms.resources.resourcegroups.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index b18df4e10a..8983f98175 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -119,6 +119,7 @@ jobs: # Get Service Principal Object ID $context = Get-AzContext + Write-Output 'Checking context' $context $servicePrincipalAppId = $context.Account.Id $servicePrincipal = Get-AzADServicePrincipal -ApplicationId $servicePrincipalAppId From 598fa9330c12bc119baeec65b3ab768428d971c2 Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 16:38:12 +0200 Subject: [PATCH 10/13] Adding setEnvironmentVariables --- .github/workflows/ms.resources.resourcegroups.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index 8983f98175..17b2bbcef7 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -88,7 +88,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 - + - name: Set environment variables + uses: ./.github/actions/templates/setEnvironmentVariables + with: + variablesPath: ${{ env.variablesPath }} - name: Azure Login uses: Azure/login@v1 with: From f9634c0fc6d4f6f5c9a8ad3131e16fbd6fe2b22d Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 16:57:11 +0200 Subject: [PATCH 11/13] Added matrix and needs --- .github/workflows/ms.resources.resourcegroups.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index 17b2bbcef7..668e60b7c4 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -84,6 +84,12 @@ jobs: job_psrule_test: name: 'PsRule Analyze repository' runs-on: ubuntu-latest + needs: + - job_initialize_pipeline + strategy: + fail-fast: false + matrix: + moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }} steps: - name: Checkout From 5a02f7a210c161993382031beaa906e215168be1 Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 17:05:01 +0200 Subject: [PATCH 12/13] Testing inputPath /${{ matrix.moduleTestFilePaths }} --- .github/workflows/ms.resources.resourcegroups.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index 668e60b7c4..75f779c6d6 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -194,7 +194,7 @@ jobs: uses: microsoft/ps-rule@v2.4.0 with: modules: 'PSRule.Rules.Azure' - inputPath: 'modules/Microsoft.Resources/resourceGroups/' + inputPath: 'modules/Microsoft.Resources/resourceGroups/${{ matrix.moduleTestFilePaths }}' ############################# From 0dd65263341d1e3e4510772ac22b2e1800456937 Mon Sep 17 00:00:00 2001 From: Elena Batanero Garcia Date: Mon, 19 Sep 2022 17:43:40 +0200 Subject: [PATCH 13/13] Uncommented workflow --- .../workflows/ms.resources.resourcegroups.yml | 122 +++++++++--------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/.github/workflows/ms.resources.resourcegroups.yml b/.github/workflows/ms.resources.resourcegroups.yml index 75f779c6d6..dd79505e8e 100644 --- a/.github/workflows/ms.resources.resourcegroups.yml +++ b/.github/workflows/ms.resources.resourcegroups.yml @@ -197,65 +197,65 @@ jobs: inputPath: 'modules/Microsoft.Resources/resourceGroups/${{ matrix.moduleTestFilePaths }}' - ############################# - # Deployment validation # - ############################# - # job_module_deploy_validation: - # runs-on: ubuntu-20.04 - # name: 'Deployment validation' - # needs: - # - job_initialize_pipeline - # - job_module_pester_validation - # strategy: - # fail-fast: false - # matrix: - # moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }} - # steps: - # - name: 'Checkout' - # uses: actions/checkout@v2 - # with: - # fetch-depth: 0 - # - name: Set environment variables - # uses: ./.github/actions/templates/setEnvironmentVariables - # with: - # variablesPath: ${{ env.variablesPath }} - # - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' - # uses: ./.github/actions/templates/validateModuleDeployment - # with: - # templateFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' - # location: '${{ env.location }}' - # resourceGroupName: '${{ env.resourceGroupName }}' - # subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' - # managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' - # removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}' + ############################ + # Deployment validation # + ############################ + job_module_deploy_validation: + runs-on: ubuntu-20.04 + name: 'Deployment validation' + needs: + - job_initialize_pipeline + - job_module_pester_validation + strategy: + fail-fast: false + matrix: + moduleTestFilePaths: ${{ fromJSON(needs.job_initialize_pipeline.outputs.moduleTestFilePaths) }} + steps: + - name: 'Checkout' + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set environment variables + uses: ./.github/actions/templates/setEnvironmentVariables + with: + variablesPath: ${{ env.variablesPath }} + - name: 'Using test file [${{ matrix.moduleTestFilePaths }}]' + uses: ./.github/actions/templates/validateModuleDeployment + with: + templateFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}' + location: '${{ env.location }}' + resourceGroupName: '${{ env.resourceGroupName }}' + subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}' + managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}' + removeDeployment: '${{ needs.job_initialize_pipeline.outputs.removeDeployment }}' - # ################## - # # Publishing # - # ################## - # job_publish_module: - # name: 'Publishing' - # if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.event.inputs.prerelease == 'true' - # runs-on: ubuntu-20.04 - # needs: - # - job_module_deploy_validation - # steps: - # - name: 'Checkout' - # uses: actions/checkout@v2 - # with: - # fetch-depth: 0 - # - name: Set environment variables - # uses: ./.github/actions/templates/setEnvironmentVariables - # with: - # variablesPath: ${{ env.variablesPath }} - # - name: 'Publishing' - # uses: ./.github/actions/templates/publishModule - # with: - # templateFilePath: '${{ env.modulePath }}/deploy.bicep' - # templateSpecsRGName: '${{ env.templateSpecsRGName }}' - # templateSpecsRGLocation: '${{ env.templateSpecsRGLocation }}' - # templateSpecsDescription: '${{ env.templateSpecsDescription }}' - # templateSpecsDoPublish: '${{ env.templateSpecsDoPublish }}' - # bicepRegistryName: '${{ env.bicepRegistryName }}' - # bicepRegistryRGName: '${{ env.bicepRegistryRGName }}' - # bicepRegistryRgLocation: '${{ env.bicepRegistryRgLocation }}' - # bicepRegistryDoPublish: '${{ env.bicepRegistryDoPublish }}' + ################## + # Publishing # + ################## + job_publish_module: + name: 'Publishing' + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.event.inputs.prerelease == 'true' + runs-on: ubuntu-20.04 + needs: + - job_module_deploy_validation + steps: + - name: 'Checkout' + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set environment variables + uses: ./.github/actions/templates/setEnvironmentVariables + with: + variablesPath: ${{ env.variablesPath }} + - name: 'Publishing' + uses: ./.github/actions/templates/publishModule + with: + templateFilePath: '${{ env.modulePath }}/deploy.bicep' + templateSpecsRGName: '${{ env.templateSpecsRGName }}' + templateSpecsRGLocation: '${{ env.templateSpecsRGLocation }}' + templateSpecsDescription: '${{ env.templateSpecsDescription }}' + templateSpecsDoPublish: '${{ env.templateSpecsDoPublish }}' + bicepRegistryName: '${{ env.bicepRegistryName }}' + bicepRegistryRGName: '${{ env.bicepRegistryRGName }}' + bicepRegistryRgLocation: '${{ env.bicepRegistryRgLocation }}' + bicepRegistryDoPublish: '${{ env.bicepRegistryDoPublish }}'