-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdevops_deployLoan.yaml
More file actions
119 lines (111 loc) · 3.46 KB
/
Copy pathdevops_deployLoan.yaml
File metadata and controls
119 lines (111 loc) · 3.46 KB
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
version: "1.0"
stages:
- clone
- prep
- deploy
hooks:
on_fail:
steps:
exec:
type: slack-post-channel:0.0.7
arguments:
SLACK_TOKEN: ${{LR_SLACK_TOKEN}}
SLACK_CHANNEL: ${{SLACK_CHANNEL}}
SLACK_MESSAGE: "Loan deployment build for ${{APPNAME}} failed. See ${{CF_BUILD_URL}}"
steps:
clone:
title: "Cloning repository"
type: "git-clone"
repo: "aperture-sci/DevOps"
depth: 1
revision: "main"
git: github-lr
stage: clone
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/$SERVICE/$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
create_branch:
title: "Create temp branch"
image: maniator/gh
working_directory: ${{clone}}
stage: prep
commands:
- |
export BRANCH="loan-dev-temp-$(date +%s)"
cf_export BRANCH=$BRANCH
git checkout -b $BRANCH
on_success:
annotations:
set:
- annotations:
- image: ${{SERVICE}}:${{TAG}}
display: image
bumpVersion:
type: semversioner:0.1.6
stage: prep
arguments:
SEMVERSIONER_VERSION: ${{CVERSION}}
SEMVERSIONER_ACTION: bump
SEMVERSIONER_PART: ${{PART}}
update_ENV_manifest:
stage: deploy
title: "update the image version"
image: mikefarah/yq:3.3.4
working_directory: ${{clone}}
commands:
- cf_export APPVERSION=${{steps.bumpVersion.output.SEMVERSIONER_RESULT}}
- yq w -i manifests/$APPNAME/$SERVICE/$APPENV/values.yaml 'loans.image.tag' "${{TAG}}"
- cat manifests/$APPNAME/$SERVICE/$APPENV/values.yaml
- yq w -i manifests/$APPNAME/$SERVICE/$APPENV/Chart.yaml 'appVersion' "${{steps.bumpVersion.output.SEMVERSIONER_RESULT}}"
- cat manifests/$APPNAME/$SERVICE/$APPENV/Chart.yaml
create_pr:
title: "Create ENV PR"
image: lrochette/ghssh:0.0.4
working_directory: ${{clone}}
stage: deploy
commands:
- |-
echo "Setup ssh"
mkdir -p ~/.ssh
echo "${SSH_KEY}" | tr ',' '\n' > ~/.ssh/id_ed25519
touch ~/.ssh/known_hosts
chmod 0600 ~/.ssh/*
chmod 0700 ~/.ssh
ssh-keygen -R github.com
ssh-keyscan -H github.com >> ~/.ssh/known_hosts 2> >(grep -v '^#' >&2)
- |-
echo "Setup git"
git config --global user.email "laurent.rochette@octopus.com"
git config --global user.name "Laurent Rochette"
git add \
manifests/$APPNAME/$SERVICE/$APPENV/values.yaml \
manifests/$APPNAME/$SERVICE/$APPENV/Chart.yaml
git commit -m "[promotion:sequential-${{SERVICE}}] Update image tag for ${{SERVICE}} and bump Chart version"
git push -u origin "$BRANCH"
- |-
echo "Create PR"
gh pr create -B main -H "$BRANCH" \
-t "Automated PR to push Dev tag $TAG" \
-b "This PR updates the content of the file as part of an automated workflow."
- |-
echo "merge PR"
gh pr merge "$BRANCH" --merge --delete-branch
on_success:
annotations:
set:
- annotations:
- appVersion: ${{APPVERSION}}