-
Notifications
You must be signed in to change notification settings - Fork 12
/
tasks.yaml
179 lines (175 loc) · 5.44 KB
/
tasks.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: detect-change-task
spec:
results:
- name: is_app
description: changed files belong to app
- name: is_toolchain
description: changed files belong to toolchain
workspaces:
- name: task-workspace
mountPath: /working
params:
- name: toolchain-dirs
- name: app-dirs
- name: generic-dirs
- name: git-repository
- name: git-branch
steps:
- name: execute-script
image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.28
envFrom:
- configMapRef:
name: environment-properties
- secretRef:
name: secure-properties
env:
- name: toolchaindirs
value: $(params.toolchain-dirs)
- name: appdirs
value: $(params.app-dirs)
- name: genericdirs
value: $(params.generic-dirs)
- name: GIT_BRANCH
value: $(params.git-branch)
- name: GIT_REPO
value: $(params.git-repository)
command: ["/bin/bash", "-c"]
args:
- |
cd /working
echo "going to check for changes in git repository..."
# get the right repo and branch
if [ -z $GIT_BRANCH ]; then
git clone -q $GIT_REPO .
else
git clone -q -b $GIT_BRANCH $GIT_REPO .
fi
# check for changed directories
changed_directories=$(git log --format= -n 1 --name-only | grep / | awk 'BEGIN {FS="/"} {print $1}' | uniq)
echo "changed_directories: $changed_directories"
# check if it is toolchain-related
echo -e "\nChanged toolchain sources? "
CHANGED_TOOLCHAIN=false
for d in ${toolchaindirs[@]}; do
if [[ " ${changed_directories[@]} " =~ "${d}" ]]; then
export CHANGED_TOOLCHAIN=true
break
fi
done
printf $CHANGED_TOOLCHAIN | tee $(results.is_toolchain.path)
# check if it is app-related
echo -e "\n\nChanged app sources? "
CHANGED_APP=false
for d in ${appdirs[@]}; do
if [[ " ${changed_directories[@]} " =~ "${d}" ]]; then
export CHANGED_APP=true
break
fi
done
printf $CHANGED_APP | tee $(results.is_app.path)
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: deploy-app
spec:
workspaces:
- name: task-workspace
mountPath: /working
params:
- name: schematics-workspace-id
- name: target-region
- name: image-repository
steps:
- name: execute-script
image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.28
envFrom:
- configMapRef:
name: environment-properties
- secretRef:
name: secure-properties
env:
- name: SCHEMATICS_WORKSPACE_NAME
value: $(params.schematics-workspace-id)
- name: REGION
value: $(params.target-region)
- name: IMAGE_REPOSITORY
value: $(params.image-repository)
- name: PIPELINE_APIKEY
valueFrom:
secretKeyRef:
name: secure-properties
key: apikey
command: ["/bin/bash", "-c"]
args:
- |
cd /working
# if REGION is in the format 'ibm:yp:<region>' just keep the region part
export REGION=$(echo $REGION | awk -F ':' '{print $NF;}')
ibmcloud login -a cloud.ibm.com -r $REGION --apikey $PIPELINE_APIKEY
source ./scripts/pipeline-DEPLOY.sh
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: task-uninstall-app
spec:
workspaces:
- name: task-workspace
mountPath: /working
params:
- name: schematics-workspace-id
- name: target-region
- name: git-repository
- name: git-branch
- name: registry-namespace
- name: image-name
- name: registry-region
steps:
- name: execute-script
image: icr.io/continuous-delivery/pipeline/pipeline-base-ubi:3.28
envFrom:
- configMapRef:
name: environment-properties
- secretRef:
name: secure-properties
env:
- name: SCHEMATICS_WORKSPACE_NAME
value: $(params.schematics-workspace-id)
- name: REGION
value: $(params.target-region)
- name: GIT_BRANCH
value: $(params.git-branch)
- name: GIT_REPO
value: $(params.git-repository)
- name: IMAGE_NAME
value: $(params.image-name)
- name: REGISTRY_NAMESPACE
value: $(params.registry-namespace)
- name: REGISTRY_REGION
value: $(params.registry-region)
- name: PIPELINE_APIKEY
valueFrom:
secretKeyRef:
name: secure-properties
key: apikey
command: ["/bin/bash", "-c"]
args:
- |
cd /working
# get the right repo and branch
if [ -z $GIT_BRANCH ]; then
git clone -q $GIT_REPO .
else
git clone -q -b $GIT_BRANCH $GIT_REPO .
fi
# if REGION is in the format 'ibm:yp:<region>' just keep the region part
export REGION=$(echo $REGION | awk -F ':' '{print $NF;}')
# if REGISTRY_REGION is in the format 'ibm:yp:<region>' just keep the region part
export REGISTRY_REGION=$(echo $REGISTRY_REGION | awk -F ':' '{print $NF;}')
ibmcloud login -a cloud.ibm.com -r $REGION --apikey $PIPELINE_APIKEY
source ./scripts/pipeline-UNINSTALL.sh