forked from raisingthefloor/morphic-app-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
108 lines (100 loc) · 3.49 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
trigger:
branches:
include:
- master
- develop
tags:
include:
- "v*"
pool:
vmImage: 'ubuntu-18.04'
variables:
imageName: 'morphicweb'
${{ 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') }}:
newDeployTag:
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-morphicweb
type: github
endpoint: raisingthefloor
name: raisingthefloor/deploy-morphicweb
ref: $(deployRepoRef)
stages:
- stage: docker
jobs:
- job: build_and_publish_image
condition: ne(variables['imageTags'], '')
steps:
- task: Docker@2
displayName: Login to docker hub
inputs:
command: login
containerRegistry: morphicworld dockerhub
- task: [email protected]
displayName: build image
inputs:
repository: morphicworld/morphicweb
command: build
Dockerfile: Dockerfile
tags: $(imageTags)
- task: [email protected]
displayName: build and push image
inputs:
repository: morphicworld/morphicweb
command: push
Dockerfile: Dockerfile
tags: $(imageTags)
- stage: update_deploy_tag
jobs:
- job: update_deploy_tag
condition: ne(variables['newDeployTag'], '')
steps:
- checkout: deploy-morphicweb
persistCredentials: true
path: deploy-morphicweb
- task: Bash@3
env:
NEWTAG: $(newDeployTag)
BRANCH: $(deployRepoRef)
inputs:
targetType: 'inline'
workingDirectory: resources/
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/morphicweb=morphicworld/morphicweb:${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