forked from impact-space/app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
182 lines (160 loc) · 6.21 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
pr: none
pool:
vmImage: 'ubuntu-latest'
variables:
solution: '**/*.sln'
blazorProjectPath: '$(Build.SourcesDirectory)/aspnet-core/src/ImpactSpace.Core.Blazor/ImpactSpace.Core.Blazor.csproj'
dbMigratorProjectPath: '**/ImpactSpace.Core.DbMigrator/ImpactSpace.Core.DbMigrator.csproj'
testProjectPath: '**/ImpactSpace.Core.Application.Tests.csproj'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
stages:
- stage: CI
displayName: 'Continuous Integration'
jobs:
- job: BuildAndTest
displayName: 'Build and Test'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NuGetToolInstaller@1
displayName: 'Install NuGet'
- task: UseDotNet@2
displayName: 'Install .NET 7 SDK'
inputs:
packageType: 'sdk'
version: '7.x'
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: NuGetCommand@2
displayName: 'Restore NuGet packages'
inputs:
restoreSolution: '$(solution)'
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: '$(solution)'
arguments: '--configuration Release'
- task: DotNetCoreCLI@2
displayName: 'Run integration tests'
inputs:
command: 'test'
projects: '$(testProjectPath)'
arguments: '--configuration $(buildConfiguration)'
- task: PowerShell@2
displayName: 'Update appsettings.production.json for Blazor app'
inputs:
targetType: 'inline'
script: |
$sourceFilePath = "$(Build.SourcesDirectory)/aspnet-core/src/ImpactSpace.Core.Blazor/appsettings.production.json"
$content = Get-Content -Path $sourceFilePath -Raw
$updatedContent = $content `
-replace "#{AuthorityUrl}#", "$(AuthorityUrl)" `
-replace "#{BlazorSelfUrl}#", "$(BlazorSelfUrl)" `
-replace "#{DbConnectionString}#", "$(DbConnectionString)" `
-replace "#{DefaultPassPhrase}#", "$(DefaultPassPhrase)" `
-replace "#{IsSelfRegistrationEnabled}#", "$(IsSelfRegistrationEnabled)" `
-replace "#{RedirectAllowedUrls}#", "$(RedirectAllowedUrls)" `
-replace "#{RequireHttpsMetadata}#", "$(RequireHttpsMetadata)" `
-replace "#{EncryptionCertificateThumbprint}#", "$(EncryptionCertificateThumbprint)" `
-replace "#{SigningCertificateThumbprint}#", "$(SigningCertificateThumbprint)"
Set-Content -Path $sourceFilePath -Value $updatedContent
- task: DotNetCoreCLI@2
displayName: 'Install ABP CLI'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install -g Volo.Abp.Cli'
- task: NodeTool@0
displayName: 'Install Node.js'
inputs:
versionSpec: '18.x'
- task: CmdLine@2
displayName: 'ABP Install Libs for Blazor app'
inputs:
script: |
abp install-libs --project-path $(blazorProjectPath)
- task: DotNetCoreCLI@2
displayName: 'Publish Blazor app'
inputs:
command: 'publish'
projects: '$(blazorProjectPath)'
arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)/blazor_app'
- task: PowerShell@2
displayName: 'Update appsettings.json for DbMigrator'
inputs:
targetType: 'inline'
script: |
$sourceFilePath = "$(Build.SourcesDirectory)/aspnet-core/src/ImpactSpace.Core.DbMigrator/appsettings.production.json"
$destinationFilePath = "$(Build.SourcesDirectory)/aspnet-core/src/ImpactSpace.Core.DbMigrator/appsettings.json"
$content = Get-Content -Path $sourceFilePath -Raw
$updatedContent = $content.Replace("#{DbConnectionString}#", "$(DbConnectionString)")
Set-Content -Path $destinationFilePath -Value $updatedContent
- task: DotNetCoreCLI@2
displayName: 'Publish DbMigrator'
inputs:
command: 'publish'
publishWebProjects: false
projects: '$(dbMigratorProjectPath)'
arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)/db_migrator'
- task: PublishPipelineArtifact@1
displayName: 'Publish pipeline artifacts'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifact: 'drop'
- stage: CD
displayName: 'Continuous Deployment'
dependsOn: CI
condition: succeeded('CI')
jobs:
- deployment: RunDbMigrator
displayName: 'Run DbMigrator'
pool:
vmImage: 'ubuntu-latest'
environment: 'Production'
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'drop'
targetPath: '$(Pipeline.Workspace)'
- task: ExtractFiles@1
displayName: 'Extract DbMigrator files'
inputs:
archiveFilePatterns: '$(Pipeline.Workspace)/db_migrator/ImpactSpace.Core.DbMigrator.zip'
destinationFolder: '$(System.DefaultWorkingDirectory)/extracted_db_migrator'
cleanDestinationFolder: true
- task: AzureCLI@2
displayName: 'Run DbMigrator'
inputs:
azureSubscription: 'Impact Space'
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
cd $(System.DefaultWorkingDirectory)/extracted_db_migrator
dotnet ./ImpactSpace.Core.DbMigrator.dll
- deployment: DeployBlazorApp
dependsOn: RunDbMigrator
displayName: 'Deploy Blazor App'
pool:
vmImage: 'ubuntu-latest'
environment: 'Production'
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'drop'
targetPath: '$(Pipeline.Workspace)'
- task: AzureWebApp@1
displayName: 'Deploy Blazor App to Azure App Service'
inputs:
appType: webAppLinux
azureSubscription: 'Impact Space'
appName: 'impactspace'
package: '$(Pipeline.Workspace)/blazor_app/ImpactSpace.Core.Blazor.zip'