-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtekton-kustomize.yml
143 lines (82 loc) · 2.65 KB
/
tekton-kustomize.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
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
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
annotations:
tekton.dev/pipelines.minVersion: 0.12.1
tekton.dev/tags: git
name: git-update-deployment
namespace: workshop-int
labels:
app.kubernetes.io/version: "0.1"
operator.tekton.dev/provider-type: community
spec:
description: This Task can be used to update image digest in a Git repo using kustomize
params:
- name: GIT_REPOSITORY
type: string
- name: CURRENT_IMAGE
type: string
- name: NEW_IMAGE
type: string
- name: NEW_DIGEST
type: string
- name: KUSTOMIZATION_PATH
type: string
results:
- description: The commit SHA
name: commit
steps:
- image: "docker.io/alpine/git:v2.26.2"
name: git-clone
resources: {}
script: |
rm -rf git-update-digest-workdir
git clone $(params.GIT_REPOSITORY) git-update-digest-workdir
workingDir: $(workspaces.workspace.path)
- image: "quay.io/wpernath/kustomize-ubi:latest"
name: update-digest
resources: {}
script: >
#!/usr/bin/env bash
echo "Start"
pwd
cd git-update-digest-workdir/$(params.KUSTOMIZATION_PATH)
pwd
#echo "kustomize edit set image
#$(params.CURRENT_IMAGE)=$(params.NEW_IMAGE)@$(params.NEW_DIGEST)"
kustomize version
kustomize edit set image
$(params.CURRENT_IMAGE)=$(params.NEW_IMAGE)@$(params.NEW_DIGEST)
echo "##########################"
echo "### kustomization.yaml ###"
echo "##########################"
ls
cat kustomization.yaml
workingDir: $(workspaces.workspace.path)
- image: "docker.io/alpine/git:v2.26.2"
name: git-commit
resources: {}
script: >
pwd
cd git-update-digest-workdir
git config user.email "[email protected]"
git config user.name "tekton-pipelines-ci"
git status
git add $(params.KUSTOMIZATION_PATH)/kustomization.yaml
# git commit -m "[$(context.pipelineRun.name)] Image digest updated"
git status
git commit -m "[ci] Image digest updated"
git status
git push
RESULT_SHA="$(git rev-parse HEAD | tr -d '\n')"
EXIT_CODE="$?"
if [ "$EXIT_CODE" != 0 ]
then
exit $EXIT_CODE
fi
# Make sure we don't add a trailing newline to the result!
echo -n "$RESULT_SHA" > $(results.commit.path)
workingDir: $(workspaces.workspace.path)
workspaces:
- description: The workspace consisting of maven project.
name: workspace