-
-
Notifications
You must be signed in to change notification settings - Fork 15
130 lines (122 loc) · 4.73 KB
/
deploy-azure.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
name: Build and Deploy Azure
on: workflow_dispatch
permissions:
contents: read
actions: read
checks: write
env:
IS_CI_BUILD: 'true'
SOLUTION_PATH: 'src/SaaStack.sln'
DEPLOY_BUILD_CONFIGURATION: 'ReleaseForDeploy'
DOTNET_VERSION: 8.0.302
NODEJS_VERSION: '22'
HOSTED_ON: 'HOSTEDONAZURE'
jobs:
build:
runs-on: windows-latest
timeout-minutes: 15
environment: 'Demo'
steps:
- uses: actions/checkout@v3
- name: Install .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{env.DOTNET_VERSION}}
- name: Install NodeJs
uses: actions/setup-node@v4
with:
node-version: ${{env.NODEJS_VERSION}}
- name: Restore dependencies
run: dotnet restore "${{env.SOLUTION_PATH}}"
- name: Build Custom GitHub Actions
run: |
cd src/Tools.GitHubActions/VariableSubstitution
npm ci --cache .npm --prefer-offline
npm run build
- name: Build (Backend) for Deploy
run: dotnet build --configuration ${{env.DEPLOY_BUILD_CONFIGURATION}} "${{env.SOLUTION_PATH}}" /p:HostingPlatform=${{env.HOSTED_ON}}
- name: Substitute (Frontend) GitHub Secrets/Variables
uses: ./src/Tools.GitHubActions/VariableSubstitution
with:
files: 'src/WebsiteHost/**/.env.deploy'
variables: ${{ toJSON(vars)}}
secrets: ${{ toJSON(secrets)}}
warnOnAdditionalVars: false
- name: Build WebsiteHost (FrontEnd) for Deploy
run: |
cd src/WebsiteHost/ClientApp
npm ci --cache .npm --prefer-offline
npm run build:releasefordeploy
- name: Substitute (Backend) GitHub Secrets/Variables
uses: ./src/Tools.GitHubActions/VariableSubstitution
with:
files: '**/appsettings.json,**/appsettings.Azure.json'
variables: ${{ toJSON(vars)}}
secrets: ${{ toJSON(secrets)}}
warnOnAdditionalVars: true
ignoreAdditionalVars: '^DEPLOY_'
- name: Package (ApiHost1) for Deploy
run: dotnet publish --configuration ${{env.DEPLOY_BUILD_CONFIGURATION}} "src/ApiHost1/ApiHost1.csproj" --output ".\publish\ApiHost1" /p:HostingPlatform=${{env.HOSTED_ON}}
- name: Package (WebsiteHost) for Deploy
run: dotnet publish --configuration ${{env.DEPLOY_BUILD_CONFIGURATION}} "src/WebsiteHost/WebsiteHost.csproj" --output ".\publish\WebsiteHost" /p:HostingPlatform=${{env.HOSTED_ON}}
- name: Package (AzureFunctions) for Deploy
run: dotnet publish --configuration ${{env.DEPLOY_BUILD_CONFIGURATION}} "src/AzureFunctions.Api.WorkerHost/AzureFunctions.Api.WorkerHost.csproj" --output ".\publish\AzureFunctions.Api.WorkerHost" /p:HostingPlatform=${{env.HOSTED_ON}}
- name: Upload (ApiHost1) artifacts
uses: actions/upload-artifact@v4
with:
name: ApiHost1
path: ./publish/ApiHost1
- name: Upload (WebsiteHost) artifacts
uses: actions/upload-artifact@v4
with:
name: WebsiteHost
path: ./publish/WebsiteHost
- name: Upload (AzureFunctions.Api.WorkerHost) artifacts
uses: actions/upload-artifact@v4
with:
name: AzureFunctions.Api.WorkerHost
path: ./publish/AzureFunctions.Api.WorkerHost
include-hidden-files: true # HACK: see https://github.com/Azure/azure-functions-dotnet-worker/issues/1240
deploy:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: build
environment: 'Demo'
steps:
- name: Azure login
uses: azure/login@v2
with:
creds: "${{ secrets.DEPLOY_AZURE_CREDENTIALS }}"
- name: Download ApiHost1 Artifacts
uses: actions/download-artifact@v4
with:
name: ApiHost1
path: ./ApiHost1
- name: Deploy ApiHost1
uses: azure/webapps-deploy@v3
with:
app-name: "${{ vars.DEPLOY_AZURE_APIHOST1_APP_NAME }}"
package: ./ApiHost1
- name: Download WebsiteHost Artifacts
uses: actions/download-artifact@v4
with:
name: WebsiteHost
path: ./WebsiteHost
- name: Deploy WebsiteHost
uses: azure/webapps-deploy@v3
with:
app-name: "${{ vars.DEPLOY_AZURE_WEBSITEHOST_APP_NAME }}"
package: ./WebsiteHost
- name: Download AzureFunctions.Api.WorkerHost Artifacts
uses: actions/download-artifact@v4
with:
name: AzureFunctions.Api.WorkerHost
path: ./AzureFunctions.Api.WorkerHost
- name: Deploy AzureFunctions.Api.WorkerHost
uses: azure/webapps-deploy@v3
with:
app-name: "${{ vars.DEPLOY_AZURE_AZUREFUNCTIONS_APP_NAME }}"
package: ./AzureFunctions.Api.WorkerHost
- name: logout
run: |
az logout