Skip to content

Commit 6b500e4

Browse files
test automatoc release to the operatorhub
1 parent c582bcd commit 6b500e4

3 files changed

Lines changed: 175 additions & 2 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
branches: [ main ]
55
pull_request:
6-
branches: [ main ]
6+
branches: [ main_g ]
77
env:
88
kind-version: 'v0.29.0'
99
permissions:

.github/workflows/release.yaml

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
env:
88
REGISTRY: ghcr.io
99
IMAGE_REPO: ghcr.io/clickhouse
10-
VERSION: ${{ github.ref_name }}
1110

1211
permissions:
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

@@ -75,6 +95,7 @@ jobs:
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
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: test operator release to community-operators
2+
on:
3+
pull_request:
4+
branches: [ main ]
5+
6+
env:
7+
VERSION: '0.0.0'
8+
9+
permissions:
10+
packages: write
11+
attestations: write
12+
id-token: write
13+
contents: write
14+
pull-requests: read
15+
16+
jobs:
17+
generate-olm-bundle:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v6
22+
23+
- name: Build operator bundle image
24+
run: make bundle
25+
26+
- name: Compress OLM Bundle
27+
run: tar --use-compress-program zstd -cf olm-bundle-clickhouse.tzst -C bundle .
28+
29+
- name: Upload operator OLM bundle
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: olm-bundle-clickhouse
33+
path: olm-bundle-clickhouse.tzst
34+
if-no-files-found: error
35+
retention-days: 7
36+
37+
community-operators-release:
38+
runs-on: ubuntu-latest
39+
needs: [ generate-olm-bundle ]
40+
strategy:
41+
matrix:
42+
include:
43+
- upstream_repo: git@github.com:k8s-operatorhub/community-operators.git
44+
fork_repo: ClickHouse/community-operators
45+
# Add OpenShift community-operators release
46+
steps:
47+
- name: Set variables
48+
run: |
49+
echo "branch=clickhouse-operator-${{ env.VERSION }}" >> $GITHUB_ENV
50+
- name: Download ClickHouse Operator OLM bundle
51+
uses: actions/download-artifact@v4
52+
with:
53+
name: olm-bundle-clickhouse
54+
path: olm-bundle-clickhouse.tzst
55+
56+
- name: Clone community-operators
57+
uses: actions/checkout@v6
58+
with:
59+
repository: ${{ matrix.fork_repo }}
60+
path: community-operators
61+
62+
- name: Make changes and push to the fork
63+
working-directory: community-operators
64+
env:
65+
GH_TOKEN: ${{ github.token }}
66+
run: |
67+
git remote add upstream ${{ matrix.upstream_repo }}
68+
git fetch upstream main
69+
git checkout -b ${{ env.branch }} upstream/main
70+
71+
mkdir -p operators/clickhouse-operator/${{ env.VERSION }}
72+
tar -C operators/clickhouse-operator/${{ env.VERSION }} --use-compress-program="zstd -d" -xf ../olm-bundle-clickhouse.tzst
73+
74+
git add operators/
75+
76+
git config user.name 'clickhouse-operator-release[bot]'
77+
git config user.email 'operator@clickhouse.com'
78+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ matrix.fork_repo }.git
79+
80+
git commit -s -m "Update clickhouse-operator (${{ env.VERSION }})"
81+
git push origin -u origin ${{ env.branch }} -f
82+
83+
- name: Open PR to community-operators
84+
working-directory: community-operators
85+
env:
86+
GH_TOKEN: ${{ github.token }}
87+
run: |
88+
prOpen=$(gh pr view ${{ env.branch }} -R ${{ matrix.upstream_repo }} --json closed --jq '.closed' 2>/dev/null | grep -q false && echo "true" || echo "false")
89+
90+
if [[ "$prOpen" == "false" ]]; then
91+
gh pr create --title "Update clickhouse-operator (${{ env.VERSION }})" --repo ${{ matrix.upstream_repo }} --base main -F docs/pull_request_template.md --head ${{ matrix.fork_repo }}
92+
else
93+
echo "PR already exists, skipping..."
94+
fi

0 commit comments

Comments
 (0)