-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
117 lines (102 loc) · 3.65 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
name: Opdex-API
trigger:
- main
pool:
vmImage: ubuntu-latest
variables:
location: "Central US"
azureSubscription: "sub-opdex-dev"
ARTIFACT_NAME: platform-api
releaseTemplate: "azure-pipelines.release.yml"
stages:
- stage: CI
displayName: "Continuous Integration"
jobs:
- job: Build
displayName: Build and Publish
variables:
SOLUTION: "Opdex.sln"
BUILD_CONFIGURATION: "Release"
IMAGE_REPOSITORY: "opdex-v1-api"
DOCKERFILE_PATH: "src/Opdex.Platform.WebApi/Dockerfile"
TAG: "$(Build.SourceVersion)"
steps:
- task: UseDotNet@2 # https://github.com/dotnet/core/issues/6907
inputs:
packageType: "sdk"
version: "6.0.x"
displayName: Use .NET 6.0
- task: DotNetCoreCLI@2
inputs:
command: "restore"
projects: $(SOLUTION)
displayName: Restore
- task: DotNetCoreCLI@2
inputs:
command: "build"
projects: $(SOLUTION)
arguments: "--configuration $(BUILD_CONFIGURATION) --no-restore"
displayName: "Build"
- task: DotNetCoreCLI@2
inputs:
command: "test"
projects: test/**/*.Tests.csproj
arguments: "--configuration $(BUILD_CONFIGURATION) --no-build"
displayName: "Unit Test"
- task: DotNetCoreCLI@2
inputs:
command: "publish"
projects: $(SOLUTION)
publishWebProjects: True
arguments: "--configuration $(BUILD_CONFIGURATION) --no-build --output $(Build.ArtifactStagingDirectory)"
zipAfterPublish: False
displayName: Publish
- task: Docker@2
inputs:
containerRegistry: "acr-opdex"
repository: "$(IMAGE_REPOSITORY)"
command: "buildAndPush"
Dockerfile: "$(DOCKERFILE_PATH)"
buildContext: "$(Build.ArtifactStagingDirectory)/Opdex.Platform.WebApi"
tags: "$(TAG)"
displayName: Docker
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: "$(Build.ArtifactStagingDirectory)"
artifactName: "$(ARTIFACT_NAME)"
displayName: Share
# - stage: DEV
# displayName: "Release to devnet (Azure)"
# dependsOn: CI
# condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) # Don't run deployment for PRs against the branch.
# jobs:
# - template: ${{ variables.releaseTemplate }}
# parameters:
# environment: "dev"
- stage: TEST
displayName: "Release to testnet (Azure)"
dependsOn: CI
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) # Don't run deployment for PRs against the branch.
jobs:
- template: ${{ variables.releaseTemplate }}
parameters:
environment: "test"
# - job:
# displayName: "ReadMe Docs"
# steps:
# - task: CmdLine@2
# displayName: Sync OpenAPI doc
# inputs:
# script: |
# npm install rdme
# npx rdme openapi $(Build.SourcesDirectory)/docs/openapi.yml --id=61161540149ab80029bab5ca --key=$(README_API_KEY)
# env:
# README_API_KEY: $(README_API_KEY)
# dependsOn: "test" # template deployment name == parameters.environment
- stage: MAIN
displayName: "Release to mainnet (Azure)"
dependsOn: TEST
jobs:
- template: ${{ variables.releaseTemplate }}
parameters:
environment: "main"