-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
141 lines (113 loc) · 4.04 KB
/
azure-pipelines.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
131
132
133
134
135
136
137
138
139
140
141
# API must be deployed first because wwwroot folder is deleted on deploy.
# This behavior may be related to WEBSITE_RUN_FROM_PACKAGE setting
# which can be controlled by appSettings argument to AzureWebAp@1 task.
# See https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-rm-web-app?view=azure-devops
# Reference:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
# https://joeblogs.technology/2020/07/multi-stage-pipelines-and-yaml-for-continuous-delivery-azure-devops/
# https://dev.to/mcklmt/build-and-deploy-angular-app-with-azure-devops-3nnf
# Build, test, and deploy JavaScript and Node.js apps
# https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/javascript?view=azure-devops&tabs=code
# Deploy an Azure Web App
# https://docs.microsoft.com/en-us/azure/devops/pipelines/targets/webapp?view=azure-devops&tabs=windows%2Cyaml
# Support ticket
# https://developercommunity.visualstudio.com/t/Azure-pipeline-cannot-find-published-art/1618079?space=22&entry=myfeedback
# stage / job / step / task
trigger:
tags:
include:
- release/*
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
project: '**/Blog.API/Blog.API.csproj'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
azureSubscription: 'Pay as you go subscription'
appName: 'SamWheatWeb'
system.debug: false
steps:
# Build and deploy API
- task: UseDotNet@2
displayName: 'Use dotnet 8'
inputs:
packageType: 'sdk'
version: '8.x'
- task: DotNetCoreCLI@2
displayName: 'DotNet Restore NuGet packages'
inputs:
command: 'restore'
feedsToUse: 'select'
vstsFeed: 'LeaderAnalyticsFeed'
includeNuGetOrg: true
- task: DownloadSecureFile@1
name: appsettingsProd
displayName: 'Get appsettings.Production.json from Secure File storage'
inputs:
secureFile: 'appsettings.Production.json'
- powershell: |
Copy-Item $(appsettingsProd.secureFilePath) -Destination $(Build.SourcesDirectory)/Blog.API
displayName: Copy appsettings.Production.json from temp to source folder
- script: dotnet build --configuration $(buildConfiguration)
displayName: 'dotnet build $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'DotNet publish'
inputs:
command: publish
publishWebProjects: true
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingdirectory) --self-contained'
zipAfterPublish: true
- task: AzureRmWebAppDeployment@4
displayName: 'AzureRmWebAppDeployment@3'
inputs:
ConnectionType: 'AzureRM'
azureSubscription: $(azureSubscription)
appType: webApp
WebAppName: $(appName)
UseWebDeploy: true
virtualApplication: '/api'
packageforLinux: '$(Build.ArtifactStagingDirectory)/*.zip'
# Install dependencies
- script: |
npm install [email protected] -g
displayName: Install specific version of npm
- task: NuGetToolInstaller@1
displayName: 'Install NuGet'
# Build and deploy WebApp
- script: |
cd Blog/ClientApp
npm --version
displayName: 'verify npm version'
- script: |
cd Blog/ClientApp
npm install
displayName: 'npm install'
- script: |
cd Blog/ClientApp
npm run build:prod
displayName: 'npm build'
- task: CopyFiles@2
inputs:
Contents: 'Blog/ClientApp/dist/**'
TargetFolder: '$(Build.ArtifactStagingDirectory)/web'
- task: AzureWebApp@1
displayName: 'Deploy Azure Web App'
inputs:
azureSubscription: $(azureSubscription)
appType: webApp
appName: $(appName)
package: '$(Build.ArtifactStagingDirectory)/web/Blog/ClientApp/dist/'
# Build and execute database migrations
- task: DotNetCoreCLI@2
displayName: 'Publish MigrationFactories'
inputs:
command: publish
projects: '**/Blog.MigrationFactories.csproj'
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingdirectory) --self-contained'
zipAfterPublish: true
- script: |
cd $(Agent.BuildDirectory)
cd s/Blog.MigrationFactories/bin/Release/net8.0
Blog.MigrationFactories.exe
displayName: 'Deploy Database Migrations'