1
+ name : Create Azure Resources
2
+ on :
3
+ workflow_dispatch :
4
+ inputs :
5
+ # Validate the bicep scripts and (optionally) create the Azure resources
6
+ DEPLOYMENT_MODE :
7
+ description : ' Deployment Mode'
8
+ type : choice
9
+ required : true
10
+ default : ' validate'
11
+ options :
12
+ - ' validate'
13
+ - ' validate and deploy'
14
+ # Azure region to deploy most of the Azure resources
15
+ AZURE_REGION :
16
+ description : ' Azure Region to deploy resources (e.g. eastus)'
17
+ required : true
18
+ default : ' eastus'
19
+ # Azure resource group where the services in the bicep scripts will be created
20
+ RESOURCE_GROUP_NAME :
21
+ description : ' Azure Resource Group to deploy resources'
22
+ required : true
23
+ default : ' rg-functionsdemo-dev'
24
+ # Azure services suffix
25
+ ENVIRONMENT_TYPE :
26
+ type : choice
27
+ description : ' Azure Environment'
28
+ required : true
29
+ default : ' dev'
30
+ options :
31
+ - ' dev'
32
+ - ' qa'
33
+ - ' uat'
34
+ - ' prod'
35
+
36
+ # CONFIGURATION
37
+ # For help, go to https://github.com/Azure/Actions
38
+ #
39
+ # 1. Set up the following secrets in your repository:
40
+ # AZURE_CREDENTIALS
41
+ #
42
+ # 2. Change below variables for your configuration:
43
+ env :
44
+ AZURE_REGION : ${{ github.event.inputs.AZURE_REGION }}
45
+ ENVIRONMENT_TYPE : ${{ github.event.inputs.ENVIRONMENT_TYPE }}
46
+ RESOURCE_GROUP_NAME : ${{ github.event.inputs.RESOURCE_GROUP_NAME }}
47
+ BICEP_FILE_PATH : ' ./Infrastructure/main.bicep'
48
+
49
+ jobs :
50
+ validate_and_deploy :
51
+ runs-on : ubuntu-latest
52
+ environment : ${{ inputs.ENVIRONMENT_TYPE }}
53
+ steps :
54
+ # Authentication
55
+ # Set up the following secrets in your repository: AZURE_CREDENTIALS
56
+ # For details on usage of secrets, please refer https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
57
+ - name : Azure Login
58
+
59
+ with :
60
+ creds : ${{ secrets.AZURE_CREDENTIALS }}
61
+
62
+ # Checkout
63
+ - name : Checkout
64
+ uses : actions/checkout@v4
65
+
66
+ # Build ARM Template from Bicep and create a target Azure resource group
67
+ - name : Validate Bicep file ${{ env.BICEP_FILE_PATH }}
68
+ uses : azure/CLI@v1
69
+ with :
70
+ # Specify the script here
71
+ inlineScript : |
72
+ az group create -l ${{ env.AZURE_REGION }} -n ${{ env.RESOURCE_GROUP_NAME }}
73
+ az deployment group validate -g ${{ env.RESOURCE_GROUP_NAME }} --name MGSBicepDeployment --template-file ./${{ env.BICEP_FILE_PATH }} --parameters environment=${{ env.ENVIRONMENT_TYPE }}
74
+
75
+ # Build ARM Template from Bicep and create a target Azure resource group
76
+ - name : Deploy Bicep file ${{ env.BICEP_FILE_PATH }}
77
+ if : ${{ inputs.DEPLOYMENT_MODE == 'validate and deploy' }}
78
+ uses : azure/CLI@v1
79
+ with :
80
+ # Specify the script here
81
+ inlineScript : |
82
+ az deployment group create -g ${{ env.RESOURCE_GROUP_NAME }} --name MGSBicepDeployment --template-file ./${{ env.BICEP_FILE_PATH }} --parameters environment=${{ env.ENVIRONMENT_TYPE }}
83
+
84
+ # Azure logout
85
+ - name : logout
86
+ run : |
87
+ az logout
88
+ if : always()
0 commit comments