-
Notifications
You must be signed in to change notification settings - Fork 1
155 lines (129 loc) · 4.52 KB
/
azure-dev.yaml
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
name: 'Azure Dev'
on:
workflow_dispatch:
push:
branches:
- main
- 'feature/*'
pull_request:
branches:
- main
permissions:
id-token: write
contents: read
env:
AZURE_RESOURCE_GROUP_NAME: 'rg-${{ vars.AZURE_ENV_NAME }}'
AZURE_FNCAPP_NAME: 'fncapp-${{ vars.AZURE_ENV_NAME }}'
AZURE_APIM_NAME: 'apim-${{ vars.AZURE_ENV_NAME }}'
# AZURE_STTAPP_NAME: 'sttapp-${{ vars.AZURE_ENV_NAME }}'
AZURE_OPENAI_NAME: 'aoai-${{ vars.AZURE_ENV_NAME }}'
jobs:
build-test:
name: Build Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
- name: Restore NuGet packages
shell: bash
run: |
dotnet restore
- name: Build solution
shell: bash
run: |
dotnet build -c Release
- name: Test solution
shell: bash
run: |
dotnet test -c Release
- name: Create artifacts
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
shell: bash
run: |
dotnet publish -c Release
- name: Upload artifact - API
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v3
with:
name: apiapp
path: src/YouTubeSummariser.ApiApp/bin/Release/net7.0/publish
deploy:
name: Deploy
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
needs:
- build-test
runs-on: ubuntu-latest
steps:
- name: Download artifact - API
uses: actions/download-artifact@v3
with:
name: apiapp
path: published/apiapp
- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- name: Deploy Azure - API
uses: azure/webapps-deploy@v2
with:
app-name: '${{ env.AZURE_FNCAPP_NAME }}-aoai'
package: published/apiapp
# - name: Get SWA token
# shell: bash
# run: |
# swa_token=$(az staticwebapp secrets list \
# -g ${{ env.AZURE_RESOURCE_GROUP_NAME }} \
# -n ${{ env.AZURE_STTAPP_NAME }}-web \
# --query "properties.apiKey" -o tsv)
# echo "::add-mask::$swa_token"
# echo "SWA_TOKEN=$swa_token" >> $GITHUB_ENV
# - name: Deploy Azure - Web
# uses: Azure/static-web-apps-deploy@v1
# with:
# azure_static_web_apps_api_token: ${{ env.SWA_TOKEN }}
# action: "upload"
# app_location: 'src/YouTubeSummariser.WebApp.Wasm'
# api_location: ''
# # api_location: 'src/YouTubeSummariser.ApiApp'
# output_location: 'wwwroot'
# # app_build_command: 'dotnet publish -c Release -o bin'
# # api_build_command: 'dotnet publish -c Release'
- name: Update APIM settings
shell: bash
run: |
functionKey=$(az functionapp keys list \
--resource-group "${{ env.AZURE_RESOURCE_GROUP_NAME }}" \
--name "${{ env.AZURE_FNCAPP_NAME }}-aoai" \
--query "functionKeys.default" \
--output tsv)
nv=$(az apim nv update \
--resource-group ${{ env.AZURE_RESOURCE_GROUP_NAME }} \
--service-name ${{ env.AZURE_APIM_NAME }} \
--named-value-id "X_FUNCTIONS_KEY_AOAI" \
--value $functionKey \
--secret true)
- name: Update API settings - API
shell: bash
run: |
endpoint=$(az cognitiveservices account show \
--resource-group "${{ env.AZURE_RESOURCE_GROUP_NAME }}" \
--name "${{ env.AZURE_OPENAI_NAME }}" \
--query "properties.endpoint" -o tsv)
apikey=$(az cognitiveservices account keys list \
--resource-group "${{ env.AZURE_RESOURCE_GROUP_NAME }}" \
--name "${{ env.AZURE_OPENAI_NAME }}" \
--query "key1" -o tsv)
appsettings=$(az functionapp config appsettings set \
--resource-group "${{ env.AZURE_RESOURCE_GROUP_NAME }}" \
--name "${{ env.AZURE_FNCAPP_NAME }}-aoai" \
--settings "OpenAIApi__Endpoint=$endpoint")
appsettings=$(az functionapp config appsettings set \
--resource-group "${{ env.AZURE_RESOURCE_GROUP_NAME }}" \
--name "${{ env.AZURE_FNCAPP_NAME }}-aoai" \
--settings "OpenAIApi__AuthKey=$apikey")