Skip to content

Commit d9e5ed0

Browse files
authored
Add workflow to automatically update helm chart 0-latest release (#673)
* Add workflow to automatically update helm chart 0-latest release Signed-off-by: Dolpher Du <[email protected]> * Add Copyright Signed-off-by: Dolpher Du <[email protected]> * Add version check for e2e test Signed-off-by: Dolpher Du <[email protected]> --------- Signed-off-by: Dolpher Du <[email protected]>
1 parent 1fcde6d commit d9e5ed0

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

.github/workflows/pr-chart-e2e.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ jobs:
3434
- name: Get test matrix
3535
id: get-test-matrix
3636
run: |
37+
if grep -r '^version: ' `find helm-charts/ -name "Chart.yaml"` | grep -v "0-latest"; then
38+
echo "Version check failed, main branch should always use version 0-latest"
39+
exit 1
40+
fi
3741
base_commit=${{ github.event.pull_request.base.sha }}
3842
merged_commit=$(git log -1 --format='%H')
3943
e2e_charts=$(git diff --name-only ${base_commit} ${merged_commit} | \
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Update the helm charts 0-latest
5+
6+
on:
7+
pull_request:
8+
branches:
9+
- main
10+
types: [closed]
11+
paths:
12+
- helm-charts/**
13+
env:
14+
CHARTS_DIR: "helm-charts"
15+
16+
jobs:
17+
run-on-merge:
18+
if: github.event.pull_request.merged == true
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout Code
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
ref: ${{ github.ref }}
27+
28+
- name: Get the modified charts list
29+
run: |
30+
echo "This job runs after a PR is merged!"
31+
if grep -r '^version: ' `find helm-charts/ -name "Chart.yaml"` | grep -v "0-latest"; then
32+
echo "Version check failed, only update 0-latest"
33+
exit 1
34+
fi
35+
base_commit=${{ github.event.pull_request.base.sha }}
36+
merged_commit=$(git log -1 --format='%H')
37+
# Update components
38+
common_charts=$(git diff --name-only ${base_commit} ${merged_commit} | \
39+
grep "^$CHARTS_DIR/common" | \
40+
grep -vE 'README.md|*.sh' | \
41+
cut -d'/' -f3 | sort -u )
42+
echo "Charts to be updated: $common_charts"
43+
echo "${{ secrets.ACTION_TOKEN }}" | helm registry login ghcr.io -u opea --password-stdin
44+
pushd $CHARTS_DIR/common
45+
for chart in ${common_charts}; do
46+
echo "Updating $chart"
47+
helm dependency update ${chart}
48+
helm package $chart
49+
helm push ${chart}-0-latest.tgz oci://ghcr.io/opea-project/charts
50+
done
51+
popd
52+
# Update Examples
53+
e2e_charts=$(git diff --name-only ${base_commit} ${merged_commit} | \
54+
grep -v "common" | \
55+
grep -vE 'README.md|*.sh' | \
56+
cut -d'/' -f2 | sort -u )
57+
echo "Charts to be updated: $e2e_charts"
58+
echo "${{ secrets.ACTION_TOKEN }}" | helm registry login ghcr.io -u opea --password-stdin
59+
pushd $CHARTS_DIR
60+
for chart in ${e2e_charts}; do
61+
echo "Updating $chart"
62+
helm dependency update ${chart}
63+
helm package $chart
64+
helm push ${chart}-0-latest.tgz oci://ghcr.io/opea-project/charts
65+
done
66+
popd

0 commit comments

Comments
 (0)