-
Notifications
You must be signed in to change notification settings - Fork 5
129 lines (111 loc) · 3.54 KB
/
deployment.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
name: Azure Deployment
on:
workflow_call:
inputs:
rg:
type: string
required: true
unique-label:
type: string
required: true
secrets:
azure-client-id:
required: true
azure-tenant-id:
required: true
azure-subscription-id:
required: true
github-pat:
required: true
permissions:
id-token: write
contents: read
jobs:
Deploy-Infrastructure:
# Setup
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@main
- name: azure-login
uses: azure/login@v2
with:
client-id: ${{ secrets.azure-client-id }}
tenant-id: ${{ secrets.azure-tenant-id }}
subscription-id: ${{ secrets.azure-subscription-id }}
- name: azure-cli-verify
uses: azure/cli@v2
with:
azcliversion: latest
inlineScript: |
az account show
- name: setup-dotnet
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.0'
# Bicep
- name: bicep-install
run: az bicep upgrade
- name: generate-bicep-parameters
run: |
echo "{
\"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#\",
\"contentVersion\": \"1.0.0.0\",
\"parameters\": {
\"githubPat\": {
\"value\": \"${{ secrets.github-pat }}\"
},
\"uniqueName\": {
\"value\": \"${{ inputs.rg }}\"
}
}
}" > parameters.json
- name: bicep-deploy
uses: azure/arm-deploy@v2
with:
subscriptionId: ${{ secrets.azure-subscription-id }}
resourceGroupName: ${{ inputs.rg }}
template: ./bicep/main.bicep
failOnStdErr: false
parameters: @parameters.json
deploymentMode: Incremental
# Web App code
- name: bicep-output-webappname
uses: azure/cli@v2
with:
inlineScript: |
#!/bin/bash
outputValue=$( az deployment group show -g ${{ inputs.rg }} --name main --query properties.outputs.webAppName.value -o tsv)
echo "WebAppName=$outputValue" >> $GITHUB_ENV
- name: dotnet-build-publish-webapp
run: |
dotnet restore ./src/Web/Web.csproj
dotnet build ./src/Web/Web.csproj --configuration Release
dotnet publish ./src/Web/Web.csproj -c Release -o './src/Web/output'
- name: azure-deploy-webapp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.WebAppName }}
package: './src/Web/output'
# Function code
- name: bicep-output-functionappname
uses: azure/cli@v2
with:
inlineScript: |
#!/bin/bash
outputValue=$( az deployment group show -g ${{ inputs.rg }} --name main --query properties.outputs.functionAppName.value -o tsv)
echo "FunctionAppName=$outputValue" >> $GITHUB_ENV
- name: dotnet-build-publish-functionapp
run: |
dotnet restore ./src/Workflow/Workflow.csproj
dotnet build ./src/Workflow/Workflow.csproj --configuration Release
dotnet publish ./src/Workflow/Workflow.csproj -c Release -o './src/Workflow/output'
- name: azure-deploy-functionapp
uses: Azure/functions-action@v1.4.8
with:
app-name: ${{ env.FunctionAppName }}
package: './src/Workflow/output'
# Capture and log the Bicep outputs
- name: output-unique-name
run: |
echo "uniqueName: ${{ steps.bicep-deploy.outputs.uniqueName }}"