This repository has been archived by the owner on Jul 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathazure-pipelines-website.yml
118 lines (112 loc) · 4.06 KB
/
azure-pipelines-website.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
# Deploy a WebApp and deploy to Azure App Service
# You must add a protected variable named administratorLoginPassword with the
# password for your database to the build defintion.
# Create or edit the build pipeline for this YAML file, define the variable on
# the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
# You must add a Azure Service Connection named AzureConnection
# See https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints
trigger:
- master
resources:
- repo: self
variables:
# Agent VM image name
vmImageName: 'ubuntu-latest'
azureSubscription: 'AzureConnection'
resourceGroupName: 'berblog'
location: 'East US 2'
administratorLogin: 'beruser'
# Information for issuing JWT tokens to clients
jwtKey: 'SECRET_THAT_SHOULD_BE_SET_IN_ENVIORNMENT_VAR'
jwtIssuer: 'http://ber.YOURDOMAIN.com'
jwtAudience: 'http://ber.YOURDOMAIN.com'
jwtMobileKey: someString
jwtWebKey: someString
stages:
- stage: Build
displayName: Build stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '2.2.301'
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: 'test'
projects: './src/BerService.Tests/BerService.Tests.csproj'
arguments: '--configuration Release --filter "Category=WebAppTests"'
- task: DotNetCoreCLI@2
displayName: Publish Service
inputs:
command: 'publish'
publishWebProjects: true
arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)/service'
- task: CopyFiles@2
displayName: Copy IaC files
inputs:
SourceFolder: 'src/BerService.IaC'
Contents: '*.json'
TargetFolder: '$(Build.ArtifactStagingDirectory)/iac'
- task: PublishPipelineArtifact@1
displayName: Publish IaC Files
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/iac'
artifact: 'iac'
- task: PublishPipelineArtifact@1
displayName: Publish Zip Files
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/service'
artifact: 'service'
- stage: Deploy
displayName: Deploy stage
dependsOn: Build
jobs:
- deployment: Deploy
displayName: Deploy
pool:
# name: Default
vmImage: $(vmImageName)
environment: 'Ber'
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
targetPath: '$(Pipeline.Workspace)'
- task: AzureResourceGroupDeployment@2
displayName: 'Deploy Infra'
inputs:
azureSubscription: '$(azureSubscription)'
action: 'Create Or Update Resource Group'
resourceGroupName: '$(resourceGroupName)'
location: '$(location)'
templateLocation: 'Linked artifact'
csmFile: '$(Pipeline.Workspace)/iac/WebSiteSQLDatabase.json'
overrideParameters: '-administratorLogin $(administratorLogin) -administratorLoginPassword $(administratorLoginPassword)'
deploymentMode: 'Incremental'
deploymentOutputs: 'iac'
- task: PowerShell@2
displayName: 'Parse Website Name'
inputs:
targetType: 'inline'
script: |
$var=ConvertFrom-Json '$(iac)'
$value=$var.webSiteName.value
Write-Host "##vso[task.setvariable variable=webSiteName;]$value"
- task: AzureRmWebAppDeployment@4
displayName: 'Deploy Website'
inputs:
ConnectionType: 'AzureRM'
azureSubscription: '$(azureSubscription)'
appType: 'webApp'
WebAppName: '$(webSiteName)'
packageForLinux: '$(Pipeline.Workspace)/**/BerService.zip'
AppSettings: '-Tokens__Key $(jwtKey) -Tokens__Issuer $(jwtIssuer) -Tokens__Audience $(jwtAudience) -Tokens__Web $(jwtWebKey) -Tokens__Mobile $(jwtMobileKey)'