-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathazure-pipelines.yml
84 lines (78 loc) · 2.33 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
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
variables:
IMAGE_REGISTRY_CONNECTION: 'ACR Demo'
IMAGE_REGISTRY: 'ADODemo'
IMAGE_REPOSITORY: 'adodemo.azurecr.io'
TAG: '$(Build.BuildId)'
stages:
- stage: BuildApp
jobs:
- job: BuildPushImage
steps:
- task: Docker@2
inputs:
containerRegistry: '$(IMAGE_REGISTRY_CONNECTION)'
repository: '$(IMAGE_REPOSITORY)'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: '$(TAG)'
- stage: DeployDev
jobs:
- job: DeployDev
steps:
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'Azure'
appType: 'webAppContainer'
WebAppName: 'ADODemo-Dev'
DockerNamespace: '$(IMAGE_REGISTRY)'
DockerRepository: '$(IMAGE_REPOSITORY)'
DockerImageTag: '$(TAG)'
- stage: DeployProdAzure
jobs:
- job: ApproveRelease
timeoutInMinutes: 4320 # job times out in 3 days
pool: server
steps:
- task: ManualValidation@0
timeoutInMinutes: 1440 # task times out in 1 day
inputs:
notifyUsers: '[email protected]'
instructions: 'Please validate and approve deployment to prod'
- job: DeployProd
steps:
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'Azure'
appType: 'webAppContainer'
WebAppName: 'ADODemo-prod'
DockerNamespace: '$(IMAGE_REGISTRY)'
DockerRepository: '$(IMAGE_REPOSITORY)'
DockerImageTag: '$(TAG)'
- stage: DeployProdAWS
jobs:
- job: ApproveRelease
timeoutInMinutes: 4320 # job times out in 3 days
pool: server
steps:
- task: ManualValidation@0
timeoutInMinutes: 1440 # task times out in 1 day
inputs:
notifyUsers: '[email protected]'
instructions: 'Please validate and approve deployment to prod'
- job: DeployProd
steps:
- task: DownloadSecureFile@1
name: sshKey
inputs:
secureFile: 'adodemo-key.pem'
- script: |
sudo chmod 400 $(sshKey.secureFilePath)
ssh -o StrictHostKeyChecking=no -i $(sshKey.secureFilePath) [email protected] "
docker ps -aq | xargs docker stop | xargs docker rm &&
docker run -d -p 8080:80 $(IMAGE_REPOSITORY)/$(IMAGE_REPOSITORY):$(TAG)"