-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
63 lines (63 loc) · 1.79 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
trigger:
- main
resources:
- repo: self
pool:
vmImage: 'ubuntu-latest'
variables:
- group: 'docker-variables'
- name: repository
value: $(dockerRepository)/$(imageName)
- name: imageToDeploy
value: $(dockerRepository)/$(imageName)
- name: tag
value: '$(Build.BuildId)'
- name: buildConfiguration
value: 'Release'
- name: containerAppName
value: 'containerapp'
- name: resourceGroup
value: 'containerapp-rg'
- name: azureSubscription
value: 'AzureSubscription'
- name: dockerRegistryServiceConnection
value: 'DockerRegistry'
stages:
- stage: Build
displayName: Build
jobs:
- job: Build
displayName: Build
steps:
- template: .azdo/dotnet-steps.yml
- stage: DockerBuild
displayName: Build Docker image
dependsOn: Build
jobs:
- job: Build
displayName: Build and push docker image
steps:
- task: Docker@2
displayName: Build and push the docker image
inputs:
command: buildAndPush
containerRegistry: $(dockerRegistryServiceConnection)
repository: $(repository)
tags: |
$(tag)
latest
- stage: Deploy
displayName: Deploy docker container
dependsOn: DockerBuild
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
jobs:
- job: Deploy
displayName: Deploy the container to Azure Container Apps
steps:
- task: AzureContainerApps@1
displayName: Deploy the docker image
inputs:
azureSubscription: $(azureSubscription)
containerAppName: $(containerAppName)
resourceGroup: $(resourceGroup)
imageToDeploy: $(imageToDeploy):$(tag)