@@ -47,13 +47,19 @@ jobs:
47
47
env :
48
48
TAGS : ${{ toJson(matrix.tags) }}
49
49
run : |
50
+ # Set a default image
51
+ echo "BASE_IMAGE=${IMAGE_STAGING}" >> $GITHUB_ENV
52
+
50
53
RESULT=""
51
54
for tag in $(jq -r '.[]' <<< "${TAGS}")
52
55
do
53
56
RESULT="${RESULT},ghcr.io/${IMAGE_STAGING}:${tag}"
54
57
# If we are running the pipeline in the main branch images are pushed in both -testing and PROD repo
55
58
if [ "${GITHUB_REF#refs/heads/}" == main ]
56
59
then
60
+ # Set prod as default image
61
+ echo "BASE_IMAGE=${IMAGE_RELEASE}" >> $GITHUB_ENV
62
+
57
63
RESULT="${RESULT},ghcr.io/${IMAGE_RELEASE}:${tag}"
58
64
fi
59
65
done
@@ -103,10 +109,51 @@ jobs:
103
109
sarif_file : snyk.sarif
104
110
105
111
- name : Build and push
112
+ id : build
106
113
uses : docker/build-push-action@v5
107
114
with :
108
115
context : ${{ matrix.dir }}
109
116
file : ${{ matrix.file }}
110
117
platforms : ${{ matrix.platforms }}
111
118
push : true
112
119
tags : ${{ env.TAGS }}
120
+
121
+ - name : Create artifact
122
+ run : |
123
+ DIGEST=ghcr.io/${{ env.BASE_IMAGE }}:${{ steps.build.outputs.digest }} \
124
+ MAJOR=${{ matrix.version }} \
125
+ yq --null-input '{
126
+ "apiVersion": "postgresql.cnpg.io/v1",
127
+ "kind": "ClusterImageCatalog",
128
+ "metadata": {"name":"postgresql"},
129
+ "spec": {
130
+ "images": [
131
+ {
132
+ "major": env(MAJOR),
133
+ "image": env(DIGEST)
134
+ }
135
+ ]
136
+ }
137
+ }' > ${{ matrix.version }}.yaml
138
+
139
+ - name : Upload artifact
140
+ uses : actions/upload-artifact@v4
141
+ with :
142
+ name : ${{ matrix.version }}-clusterimagecatalog.yaml
143
+ path : ${{ matrix.version }}.yaml
144
+
145
+ image-catalog :
146
+ name : Generate ClusterImageCatalog
147
+ runs-on : ubuntu-22.04
148
+ needs : build
149
+ steps :
150
+ - name : Download artifacts
151
+ uses : actions/download-artifact@v4
152
+ with :
153
+ pattern : ' *-clusterimagecatalog.yaml'
154
+ path : clusterimagecatalog
155
+ merge-multiple : true
156
+
157
+ - name : Test ClusterImageCatalog
158
+ run : |
159
+ yq eval-all '. as $item ireduce ({}; . *+ $item )' clusterimagecatalog/*.yaml
0 commit comments