-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines-aws.yml
133 lines (122 loc) · 4.11 KB
/
azure-pipelines-aws.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
---
trigger:
branches:
include:
- master
- develop
- "release/*"
- "hotfix/*"
tags:
include:
- "v*"
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
imageName: 'morphiclite'
${{ if eq(variables['Build.SourceBranchName'], 'master') }}:
newDeployTag: stable-$(Build.BuildNumber)
deployRepoRef: master
imageTags: |
stable
stable-$(Build.BuildNumber)
${{ if eq(variables['Build.SourceBranchName'], 'develop') }}:
newDeployTag: develop-$(Build.BuildNumber)
deployRepoRef: develop
imageTags: |
latest
develop-$(Build.BuildNumber)
${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags') }}:
imageTags: |
$(Build.SourceBranchName)
# pipelines require that all repositories are accessible before you ever use them.
# Since we want to push tag changes from master to master (and develop to develop)
# but do NOT want to push tag changes on PR branches, we simply set the deploy repo
# branch to master. We won't use it anyway.
${{ if eq(variables['deployRepoRef'], '') }}:
deployRepoRef: master
resources:
containers:
- container: mongo
image: mongo
ports:
- 27017:27017
repositories:
- repository: deploy-morphiclite
type: github
endpoint: raisingthefloor
name: raisingthefloor/deploy-morphiclite
ref: $(deployRepoRef)
pool:
vmImage: "ubuntu-18.04"
stages:
- stage: Build
jobs:
- job: Build
services:
mongo: mongo
steps:
- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: 'build'
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: 'test'
- task: DotNetCoreCLI@2
displayName: Publish
inputs:
command: 'publish'
outputDir: Morphic.Server
- stage: docker
jobs:
- job: build_and_publish_image
condition: or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), eq(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
steps:
- task: Docker@2
displayName: Login to docker hub
inputs:
command: login
containerRegistry: morphicworld dockerhub
- task: [email protected]
displayName: build and push image
inputs:
repository: morphicworld/morphiclite
command: buildAndPush
Dockerfile: Dockerfile
tags: $(imageTags)
- stage: update_deploy_tag
jobs:
- job: update_deploy_tag
condition: ne(variables['newDeployTag'], '')
steps:
- checkout: deploy-morphiclite
persistCredentials: true
path: deploy-morphiclite
- task: Bash@3
env:
NEWTAG: $(newDeployTag)
BRANCH: $(deployRepoRef)
inputs:
targetType: 'inline'
workingDirectory: base/
script: |
set -e
set -x
echo "installing kustomize"
wget "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" -O install_kustomize.sh
bash install_kustomize.sh
git checkout ${BRANCH}
ls -al
echo "setting new image tag"
./kustomize edit set image morphicworld/morphiclite=morphicworld/morphiclite:${NEWTAG}
cat kustomization.yaml
git config --global user.email "[email protected]"
git config --global user.name "buildmaster"
git commit kustomization.yaml -m "buildmaster: updating tag to ${NEWTAG}"
git push