77env :
88 REGISTRY : ghcr.io
99 IMAGE_REPO : ghcr.io/clickhouse
10- VERSION : ${{ github.ref_name }}
1110
1211permissions :
1312 packages : write
@@ -38,22 +37,43 @@ jobs:
3837 steps :
3938 - name : Checkout code
4039 uses : actions/checkout@v6
40+
4141 - name : Log in to the Container registry
4242 uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
4343 with :
4444 registry : ${{ env.REGISTRY }}
4545 username : ${{ github.actor }}
4646 password : ${{ secrets.GITHUB_TOKEN }}
47+
4748 - name : Install jq
4849 uses : dcarbone/install-jq-action@v3.2.0
50+
4951 - name : Set VERSION
5052 run : echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
53+
5154 - name : Build operator bundle image
5255 run : make bundle bundle-buildx
56+
57+ - name : Compress OLM Bundle
58+ working-directory : bundle
59+ run : |
60+ tar --use-compress-program zstd -cf olm-bundle-clickhouse-${{ env.VERSION }}.tzst \
61+ --exclude '*.tar.gz' \
62+ -C bundle .
63+
64+ - name : Upload operator OLM bundle
65+ uses : actions/upload-artifact@v4
66+ with :
67+ name : olm-bundle-clickhouse
68+ path : olm-bundle-clickhouse-${{ env.VERSION }}.tzst
69+ if-no-files-found : error
70+ retention-days : 7
71+
5372 - name : Build catalog
5473 run : make catalog-buildx
5574 env :
5675 GITHUB_TOKEN : ${{ github.token }}
76+
5777 - name : Mark catalog as latest
5878 run : make catalog-push-latest
5979
7595 helm registry login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
7696 make push-helmchart
7797
98+
7899 create-release :
79100 runs-on : ubuntu-latest
80101 needs :
@@ -149,3 +170,61 @@ jobs:
149170 dist/clickhouse-operator.yaml
150171 clickhouse-operator-helm-${{env.VERSION}}.tgz
151172 clickhouse-operator_${{env.VERSION}}_*.tar.gz
173+
174+
175+ community-operators-release :
176+ runs-on : ubuntu-latest
177+ needs : [create-release]
178+ strategy :
179+ matrix :
180+ include :
181+ - upstream_repo : git@github.com:k8s-operatorhub/community-operators.git
182+ fork_repo : ClickHouse/community-operators
183+ branch_name : clickhouse-operator-${{ github.ref_name }}
184+ # Add OpenShift community-operators release
185+ steps :
186+ - name : Download ClickHouse Operator OLM bundle
187+ uses : actions/download-artifact@v4
188+ with :
189+ name : olm-bundle-clickhouse
190+ path : olm-bundle-clickhouse.tzst
191+
192+ - name : Clone community-operators
193+ uses : actions/checkout@v6
194+ with :
195+ repository : ${{ matrix.fork_repo }}
196+ path : community-operators
197+
198+ - name : Make changes and push to the fork
199+ working-directory : community-operators
200+ env :
201+ GH_TOKEN : ${{ github.token }}
202+ run : |
203+ git remote add upstream
204+ git fetch upstream main ${{ matrix.upstream_repo }}
205+ git checkout -b ${{ matrix.branch_name }} upstream/main
206+
207+ mkdir -p operators/clickhouse-operator/${{ github.ref_name }}
208+ tar -C operators/clickhouse-operator/${{ github.ref_name }} --use-compress-program="zstd -d" -xf ../olm-bundle-clickhouse.tzst
209+
210+ git add operators/
211+
212+ git config user.name 'ClickHouse Operator Release Bot'
213+ git config user.email 'operator@clickhouse.com'
214+
215+ git commit -s -m "Update clickhouse-operator (${{ github.ref_name }})"
216+ git push origin -u origin ${{ matrix.branch_name }} -f
217+
218+ - name : Open PR to community-operators
219+ working-directory : community-operators
220+ env :
221+ GH_TOKEN : ${{ github.token }}
222+ run : |
223+ prOpen=$(gh pr view ${{ matrix.branch_name }} -R ${{ matrix.upstream_repo }} --json closed --jq '.closed' 2>/dev/null | grep -q false && echo "true" || echo "false")
224+
225+
226+ if [[ "$prOpen" == "false" ]]; then
227+ gh pr create --title "Update clickhouse-operator (${{ github.ref_name }})" --repo ${{ matrix.upstream_repo }} --base main -F docs/pull_request_template.md --head ${{ matrix.fork_repo }}
228+ else
229+ echo "PR already exists, skipping..."
230+ fi
0 commit comments