forked from Azure/appservice-landing-zone-accelerator
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (73 loc) · 3.38 KB
/
LOB-ILB-ASEv3-Bicep.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
name: "AzureBicepDeploy"
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "reference-implementations/LOB-ILB-ASEv3/bicep/**"
pull_request:
branches:
- main
paths:
- "reference-implementations/LOB-ILB-ASEv3/bicep/**"
jobs:
validate_bicep:
name: "Validate Bicep files"
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Validate that bicep builds
run: az bicep build -f main.bicep
working-directory: ./reference-implementations/LOB-ILB-ASEv3/bicep
build-and-deploy:
name: "Deploy Bicep templates"
needs: validate_bicep
runs-on: ubuntu-latest
steps:
# Checkout code
- name: Checkout the code
uses: actions/checkout@main
- name: Variable substitution
uses: microsoft/variable-substitution@v1
with:
files: ./reference-implementations/LOB-ILB-ASEv3/bicep/config.yml
env:
ACCOUNT_NAME: ${{ secrets.AZURE_SUBSCRIPTION }}
- name: Install yq to parse yaml file
run: |
sudo wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.5.0/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- name: Parse config.yaml as output to GitHub Actions matrix
run: |
echo "config=$(yq e ./reference-implementations/LOB-ILB-ASEv3/bicep/config.yml -j -I=0)" >> $GITHUB_ENV
- name: Write deployment information to log
run: |
echo "Deploying to ${{ fromJson(env.config).AZURE_LOCATION }} with name prefix ${{ fromJson(env.config).RESOURCE_NAME_PREFIX }}"
# Log into Azure
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Run Preflight Validation
working-directory: ./reference-implementations/LOB-ILB-ASEv3/bicep
run: |
az deployment sub validate \
--location ${{ fromJson(env.config).AZURE_LOCATION }} \
--parameters workloadName=${{ fromJson(env.config).RESOURCE_NAME_PREFIX }} environment=${{ fromJson(env.config).ENVIRONMENT_TAG }} \
vmUsername=${{ fromJson(env.config).VM_USERNAME }} vmPassword=${{ secrets.VM_PW }} location=${{ fromJson(env.config).AZURE_LOCATION }}\
accountName=${{ secrets.ACCOUNT_NAME }} personalAccessToken=${{ secrets.PAT }} CICDAgentType=${{ fromJson(env.config).CICD_AGENT_TYPE}} \
--template-file main.bicep
# Deploy Bicep file, need to point parameters to the main.parameters.json location
- name: deploy
uses: azure/arm-deploy@v1
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
scope: subscription
region: ${{ fromJson(env.config).AZURE_LOCATION }}
deploymentName: "${{ fromJson(env.config).DEPLOYMENT_NAME }}-${{ fromJson(env.config).AZURE_LOCATION }}"
template: ./reference-implementations/LOB-ILB-ASEv3/bicep/main.bicep
parameters: >
workloadName=${{ fromJson(env.config).RESOURCE_NAME_PREFIX }} environment=${{ fromJson(env.config).ENVIRONMENT_TAG }}
vmUsername=${{ fromJson(env.config).VM_USERNAME }} vmPassword=${{ secrets.VM_PW }} location=${{ fromJson(env.config).AZURE_LOCATION }}
accountName=${{ secrets.ACCOUNT_NAME }} personalAccessToken=${{ secrets.PAT }} CICDAgentType=${{ fromJson(env.config).CICD_AGENT_TYPE}}