-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
104 lines (91 loc) · 3.14 KB
/
azure-pipelines.yml
File metadata and controls
104 lines (91 loc) · 3.14 KB
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
trigger:
- master
- staging
pr:
- master
- staging
variables:
- name: buildPlatform
value: 'Any CPU'
- name: buildConfiguration
value: 'Release'
- name: dockerTag
${{ if eq( variables['Build.SourceBranchName'], 'master' ) }}:
value: 'latest'
${{ if ne( variables['Build.SourceBranchName'], 'master' ) }}:
value: ${{ variables['Build.SourceBranchName'] }}
stages:
- stage: Build
jobs:
- job: BuildCoreData
displayName: 'Core Data WebApp'
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
useGlobalJson: true
- task: DotNetCoreCLI@2
displayName: 'Install .NET Aspire'
inputs:
command: custom
custom: 'workload '
arguments: 'install aspire --source https://api.nuget.org/v3/index.json'
- task: DotNetCoreCLI@2
displayName: 'Install GitVersion'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install --global GitVersion.Tool --version 6.0.2'
- task: DotNetCoreCLI@2
displayName: 'Update Version'
inputs:
command: 'custom'
custom: 'gitversion'
arguments: '/output buildserver /nofetch'
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: 'build'
projects: 'wwt-core-data.sln'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: 'test'
projects: 'wwt-core-data.sln'
arguments: '--configuration $(buildConfiguration)'
- bash: |
dotnet publish ./src/WWT.Web/WWT.Web.csproj --configuration $(buildConfiguration) --no-build /t:PublishContainer -p "ContainerImageTags=${{ variables.dockerTag }}" -p ContainerArchiveOutputPath=$(build.artifactStagingDirectory)/dockerImage/core-data.tar.gz
displayName: Build docker image
- publish: $(build.artifactStagingDirectory)/dockerImage
artifact: dockerImage
displayName: Publish docker image
- stage: Deploy
dependsOn: Build
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
jobs:
# This job deploys the new Docker image to Docker Hub under the `latest`
# tag, which will then trigger an update of the "stage" deployment slot of
# the Linux core data app service. To bring the new image into production,
# the stage and main slots should be "swapped" in the Azure UI, after
# warming up the new app and doing any final testing.
- job: DockerImage
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: none
- download: current
artifact: dockerImage
- bash: |
docker load -i $(Pipeline.Workspace)/dockerImage/core-data.tar.gz
displayName: Load image from artifacts
- task: Docker@2
displayName: Push image
inputs:
containerRegistry: 'worldwidetelescope@DockerHub'
repository: 'aasworldwidetelescope/core-data'
command: 'push'
tags: |
${{ variables.dockerTag }}