-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathci_cd_pipeline.yaml
72 lines (63 loc) · 2.03 KB
/
ci_cd_pipeline.yaml
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
trigger:
- main
resources:
- repo: self
pool:
vmImage: ubuntu-latest
variables:
tag: "$(Build.BuildId)"
stages:
- stage: Build
displayName: Build image
jobs:
- job: Docker
displayName: Docker
steps:
- task: Docker@2
displayName: Build and Push docker image
inputs:
containerRegistry: 'docker-hub-service-connection'
repository: 'pedroavpereiradev/book-swap-api'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: |
$(tag)
latest
- job: Artifacts
displayName: Publish Artifacts
steps:
- task: CopyFiles@2
displayName: Copy files to staging
inputs:
SourceFolder: "$(System.DefaultWorkingDirectory)"
Contents: "**/*.yaml"
TargetFolder: "$(Build.ArtifactStagingDirectory)"
- task: PublishBuildArtifacts@1
displayName: Publish Artifacts
inputs:
PathtoPublish: "$(Build.ArtifactStagingDirectory)"
ArtifactName: "manifests"
publishLocation: "Container"
- stage: Deploy
displayName: Build image
jobs:
- job: Build
pool:
vmImage: ubuntu-latest
steps:
- task: DownloadPipelineArtifact@2
displayName: Download Artifacts
inputs:
buildType: "current"
artifactName: "manifests"
itemPattern: "**/*.yaml"
targetPath: "$(System.ArtifactDirectory)"
- task: KubernetesManifest@1
displayName: Deploy
inputs:
action: 'deploy'
connectionType: 'kubernetesServiceConnection'
kubernetesServiceConnection: 'kubectl-aws-connection'
namespace: 'default'
manifests: '$(System.ArtifactDirectory)/configuration/kubernetes/deployment.yaml'
containers: 'pedroavpereiradev/book-swap-api:$(tag)'