-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathazure-pipelines-aws.yml
103 lines (93 loc) · 3.36 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
---
trigger:
branches:
include:
- master
- develop
- "release/*"
- "hotfix/*"
tags:
include:
- "v*"
variables:
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
imageName: 'morphiccommunity'
${{ 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:
repositories:
- repository: deploy-morphic-community-web
type: github
endpoint: raisingthefloor
name: raisingthefloor/deploy-morphic-community-web
ref: $(deployRepoRef)
pool:
vmImage: "ubuntu-18.04"
stages:
- 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: Docker@2
displayName: build and push image
inputs:
repository: morphicworld/morphiccommunity
command: buildAndPush
Dockerfile: Dockerfile
tags: $(imageTags)
- stage: update_deploy_tag
jobs:
- job: update_deploy_tag
condition: ne(variables['newDeployTag'], '')
steps:
- checkout: deploy-morphic-community-web
persistCredentials: true
path: deploy-morphic-community-web
- task: Bash@3
env:
NEWTAG: $(newDeployTag)
BRANCH: $(deployRepoRef)
inputs:
targetType: 'inline'
workingDirectory: resources/community-1.0/
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/morphiccommunity=morphicworld/morphiccommunity:${NEWTAG}
cat kustomization.yaml
git config --global user.email "[email protected]"
git config --global user.name "buildmaster"
git commit kustomization.yaml -m "buildmaster: updating community tag to ${NEWTAG}"
git push