forked from datawire/hello-world-python
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
124 lines (103 loc) · 3.29 KB
/
azure-pipelines.yml
File metadata and controls
124 lines (103 loc) · 3.29 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
trigger: none
#- master
resources:
- repo: self
variables:
ImageName: 'lidorlg/sample-app-python'
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: ubuntu-latest
steps:
- task: Docker@2
inputs:
containerRegistry: 'Docker Hub'
repository: '$(ImageName)'
command: 'build'
DockerFile: '**/Dockerfile'
displayName: "Build the Docker image number $(Build.BuildId)"
- task: Docker@2
inputs:
containerRegistry: 'Docker Hub'
repository: '$(ImageName)'
command: 'build'
Dockerfile: '**/Dockerfile'
tags: 'latest'
displayName: 'Build the latest Docker image'
- task: Docker@2
inputs:
containerRegistry: 'Docker Hub'
repository: '$(ImageName)'
command: 'push'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
displayName: "Push the Docker image number $(Build.BuildId) to Dockerhub"
- task: Docker@2
inputs:
containerRegistry: 'Docker Hub'
repository: '$(ImageName)'
command: 'push'
tags: 'latest'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
displayName: 'Push the latest Docker image to Dockerhub'
- stage: Provision
displayName: Provision with Terraform
jobs:
- job: Provision
displayName: Provision
pool:
vmImage: ubuntu-latest
steps:
- task: TerraformInstaller@1
displayName: Install Terraform
inputs:
terraformVersion: 'latest'
- checkout: self
displayName: 'Checkout repository'
# - task: CmdLine@2
# displayName: Create ssh key
# inputs:
# script: "ssh-keygen -t rsa -b 4096 -N '' -f $(System.DefaultWorkingDirectory)/terraform/key <<< y"
# - task: CmdLine@2
# displayName: check to see ssh keys
# inputs:
# script: 'ls $(System.DefaultWorkingDirectory)/terraform/'
- task: TerraformTaskV4@4
displayName: 'Terraform Init'
inputs:
provider: 'aws'
command: 'init'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
backendServiceAWS: 'aws'
backendAWSBucketName: 'states-tf1'
backendAWSKey: 'tf/dev/terraform.tfstate'
- task: TerraformTaskV4@4
displayName: 'Terraform Validate'
inputs:
provider: 'aws'
command: 'validate'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
- task: TerraformTaskV4@4
displayName: 'Terraform Plan'
inputs:
provider: 'aws'
command: 'plan'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
commandOptions: '-out=tfplan'
environmentServiceNameAWS: 'aws'
- task: TerraformTaskV4@4
displayName: 'Terraform Apply'
inputs:
provider: 'aws'
command: 'apply'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
commandOptions: '-auto-approve -input=false tfplan'
environmentServiceNameAWS: 'aws'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(System.DefaultWorkingDirectory)/terraform'
artifact: 'published'
publishLocation: 'pipeline'