-
Notifications
You must be signed in to change notification settings - Fork 8
/
devops_deploy.yaml
102 lines (96 loc) · 3.24 KB
/
devops_deploy.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
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
version: "1.0"
stages:
- clone
- "prep"
- "deploy"
- "test"
hooks:
on_fail:
steps:
exec:
type: slack-post-channel:0.0.7
arguments:
SLACK_TOKEN: ${{LR_SLACK_TOKEN}}
SLACK_CHANNEL: topic-codefresh-demo
SLACK_MESSAGE: "Deployment build for ${{APPNAME}} failed. See ${{CF_BUILD_URL}}"
steps:
clone:
title: "Cloning repository"
stage: "clone"
type: "git-clone"
repo: "aperture-sci/DevOps"
revision: "main"
git: github-app
depth: 1
exclude_blobs: true
get_chart_version:
title: "Get the version of the chart"
image: mikefarah/yq:3.3.4
stage: prep
working_directory: ${{clone}}
commands:
- |
CVERSION=$(yq r manifests/$APPNAME/$APPENV/Chart.yaml 'appVersion')
cf_export CVERSION=$CVERSION
export RND=$(( ( RANDOM % 100 ) + 1 ))
cf_export RND=$RND
echo "Random: $RND"
if [ $RND -le 7 ] ; then
cf_export PART="minor"
else
cf_export PART="patch"
fi
wait:
description: buffer for var to be exported properly
image: mikefarah/yq:3.3.4
stage: prep
commands:
- sleep 1
on_success:
annotations:
set:
- annotations:
- image: ${{APPNAME}}
display: image
bumpVersion:
type: semversioner:0.1.6
stage: prep
arguments:
SEMVERSIONER_VERSION: ${{CVERSION}}
SEMVERSIONER_ACTION: bump
SEMVERSIONER_PART: ${{PART}}
getimages:
title: "Get Latest Images for trio app"
working_directory: ${{clone}}
stage: "prep"
image: 'codefresh/cli'
commands:
- cf_export APPVERSION=${{steps.bumpVersion.output.SEMVERSIONER_RESULT}}
- echo "Get latest version of images"
- yq -y --arg tag "$(codefresh get images --image-name ctrlr --limit 2 --branch main -o yaml --tag main | yq -r .items[1].tag -)" '."ctrlr".image.tag = $tag' manifests/$APPNAME/$APPENV/values.yaml -i
- yq -y --arg tag "$(codefresh get images --image-name buslog --limit 2 --branch main -o yaml --tag main | yq -r .items[1].tag -)" '."buslog".image.tag = $tag' manifests/$APPNAME/$APPENV/values.yaml -i
- yq -y --arg tag "$(codefresh get images --image-name flask-ui --limit 2 --branch main -o yaml --tag main | yq -r .items[1].tag -)" '."flask-ui".image.tag = $tag' manifests/$APPNAME/$APPENV/values.yaml -i
- cat manifests/$APPNAME/$APPENV/values.yaml
- yq -y --arg tag "${{steps.bumpVersion.output.SEMVERSIONER_RESULT}}" '.appVersion = $tag' manifests/$APPNAME/$APPENV/Chart.yaml -i
- cat manifests/$APPNAME/$APPENV/Chart.yaml
commit_and_push:
title: Commit changes and push
type: git-commit:0.1.4
stage: deploy
arguments:
repo: aperture-sci/DevOps
git: github-app
working_directory: "${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}}"
commit_message: "[promotion:trio-flow] ${{COMMIT_MESSAGE}} for ${{APPENV}}"
git_user_name: todaywasawesome
git_user_email: [email protected]
allow_empty: true
force_push: true
add:
- manifests/$APPNAME/$APPENV/values.yaml
- manifests/$APPNAME/$APPENV/Chart.yaml
on_success:
annotations:
set:
- annotations:
- appVersion: ${{APPVERSION}}