forked from Azure/bicep-registry-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (159 loc) · 7.03 KB
/
avm.template.module.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: "avm.template.module"
on:
workflow_call:
inputs:
workflowInput:
type: string
description: "Input from the workflow caller in JSON format"
required: true
moduleTestFilePaths:
type: string
description: "List of relative path to the module test files in JSON format"
required: true
psRuleModuleTestFilePaths:
type: string
description: "List of relative path to the PSRule module test files in JSON format"
required: true
modulePath:
type: string
description: "Relative path to the module folder"
required: true
env:
ARM_SUBSCRIPTION_ID: "${{ secrets.ARM_SUBSCRIPTION_ID }}"
ARM_MGMTGROUP_ID: "${{ secrets.ARM_MGMTGROUP_ID }}"
ARM_TENANT_ID: "${{ secrets.ARM_TENANT_ID }}"
TOKEN_NAMEPREFIX: "${{ secrets.TOKEN_NAMEPREFIX }}"
jobs:
#########################
# Static validation #
#########################
job_module_static_validation: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners.
name: "Static validation"
runs-on: ubuntu-latest
if: (fromJson(inputs.workflowInput)).staticValidation == 'true'
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set environment
uses: ./.github/actions/templates/avm-setEnvironment
- name: "Run tests"
uses: ./.github/actions/templates/avm-validateModulePester
with:
modulePath: "${{ inputs.modulePath }}"
#########################
# PSRule validation #
#########################
job_psrule_test: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners.
name: "PSRule [${{ matrix.testCases.name }}]"
runs-on: ubuntu-latest
if: ${{ inputs.psRuleModuleTestFilePaths != '' && (fromJson(inputs.workflowInput)).staticValidation == 'true' }}
strategy:
fail-fast: false
matrix:
testCases: ${{ fromJson(inputs.psRuleModuleTestFilePaths) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set environment
uses: ./.github/actions/templates/avm-setEnvironment
- name: "Run PSRule validation with [${{ matrix.testCases.path }}]"
uses: ./.github/actions/templates/avm-validateModulePSRule
with:
templateFilePath: "${{ inputs.modulePath }}/${{ matrix.testCases.path }}"
subscriptionId: "${{ secrets.ARM_SUBSCRIPTION_ID }}"
managementGroupId: "${{ secrets.ARM_MGMTGROUP_ID }}"
psrulePath: "avm/utilities/pipelines/staticValidation/psrule" #'${{ github.workspace }}/avm'
psruleBaseline: "Azure.Default"
job_psrule_test_waf_reliability: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners.
name: "PSRule - WAF Reliability [${{ matrix.testCases.name }}]"
runs-on: ubuntu-latest
if: ${{ inputs.psRuleModuleTestFilePaths != '' && (fromJson(inputs.workflowInput)).staticValidation == 'true' }}
strategy:
fail-fast: false
matrix:
testCases: ${{ fromJson(inputs.psRuleModuleTestFilePaths) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set environment
uses: ./.github/actions/templates/avm-setEnvironment
- name: "Run PSRule validation with [${{ matrix.testCases.path }}]"
uses: ./.github/actions/templates/avm-validateModulePSRule
with:
templateFilePath: "${{ inputs.modulePath }}/${{ matrix.testCases.path }}"
subscriptionId: "${{ secrets.ARM_SUBSCRIPTION_ID }}"
managementGroupId: "${{ secrets.ARM_MGMTGROUP_ID }}"
psrulePath: "avm/utilities/pipelines/staticValidation/psrule" #'${{ github.workspace }}/avm'
psruleBaseline: "Azure.Pillar.Reliability"
#############################
# Deployment validation #
#############################
job_module_deploy_validation: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners.
name: "Deploy [${{ matrix.testCases.name}}]"
runs-on: ubuntu-latest
if: |
!cancelled() &&
(fromJson(inputs.workflowInput)).deploymentValidation == 'true' &&
needs.job_module_static_validation.result != 'failure' &&
needs.job_psrule_test_waf_reliability.result != 'failure'
needs:
- job_module_static_validation
- job_psrule_test_waf_reliability
strategy:
fail-fast: false
matrix:
testCases: ${{ fromJson(inputs.moduleTestFilePaths) }}
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set environment
uses: ./.github/actions/templates/avm-setEnvironment
with:
removeDeployment: "${{ fromJson(inputs.workflowInput).removeDeployment }}"
- name: "Run deployment validation with test file [${{ matrix.testCases.path }}]"
uses: ./.github/actions/templates/avm-validateModuleDeployment
with:
modulePath: "${{ inputs.modulePath }}"
templateFilePath: "${{ inputs.modulePath }}/${{ matrix.testCases.path }}"
deploymentMetadataLocation: "WestEurope"
subscriptionId: "${{ secrets.ARM_SUBSCRIPTION_ID }}"
managementGroupId: "${{ secrets.ARM_MGMTGROUP_ID }}"
removeDeployment: "${{ fromJson(inputs.workflowInput).removeDeployment }}"
customLocation: "${{ fromJson(inputs.workflowInput).customLocation }}"
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
##################
# Publishing #
##################
job_publish_module: # Note: Please don't change this job name. It is used by the setEnvironment action to define which PS modules to install on runners.
name: "Publishing"
runs-on: ubuntu-latest
# Note: Below always() required in condition due to psrule jobs being skipped for ptn modules not having defaults or waf-aligned folders
if: github.ref == 'refs/heads/main' &&
github.repository == 'Azure/bicep-registry-modules' &&
always() &&
needs.job_module_static_validation.result == 'success' &&
needs.job_module_deploy_validation.result == 'success'
needs:
- job_module_static_validation
- job_module_deploy_validation
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set environment
uses: ./.github/actions/templates/avm-setEnvironment
- name: "Publishing"
uses: ./.github/actions/templates/avm-publishModule
with:
templateFilePath: "${{ inputs.modulePath }}/main.bicep"
env:
PUBLISH_REGISTRY_SERVER: "${{ secrets.PUBLISH_REGISTRY_SERVER }}"
PUBLISH_CLIENT_ID: "${{ secrets.PUBLISH_CLIENT_ID }}"
PUBLISH_TENANT_ID: "${{ secrets.PUBLISH_TENANT_ID }}"
PUBLISH_SUBSCRIPTION_ID: "${{ secrets.PUBLISH_SUBSCRIPTION_ID }}"