Skip to content

Commit e5e9e8b

Browse files
Madhu-1nb-ohad
authored andcommitted
ci: add github action for helm charts
Push the operator and the csi driver helm charts to the gh-pages when there is a new release of the operator. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
1 parent 9a1f956 commit e5e9e8b

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Publish Helm Charts to GitHub Pages
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
release:
9+
name: Package and Release Helm Charts
10+
runs-on: ubuntu-latest
11+
if: github.repository == 'ceph/ceph-csi-operator'
12+
13+
permissions:
14+
contents: write
15+
packages: write
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
20+
21+
- name: Set release version
22+
id: release_version
23+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
24+
25+
26+
- name: Install helm
27+
run: |
28+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
29+
30+
- name: Install chart-releaser
31+
run: |
32+
echo "Installing chart-releaser..."
33+
curl -sSL https://github.com/helm/chart-releaser/releases/download/v1.8.1/chart-releaser_1.8.1_linux_amd64.tar.gz -o /tmp/cr-linux-amd64.tar.gz
34+
tar -xzf /tmp/cr-linux-amd64.tar.gz -C /tmp
35+
sudo chmod +x /tmp/cr
36+
sudo mv /tmp/cr /usr/local/bin/cr
37+
echo "chart-releaser installed."
38+
39+
- name: Package Helm charts
40+
run: |
41+
echo "Packaging Helm charts..."
42+
mkdir -p .csi-op-release-packages
43+
44+
sed -i "s/^version:.*/version: ${VERSION}/" "deploy/charts/ceph-csi-operator/Chart.yaml"
45+
sed -i "s/^version:.*/version: ${VERSION}/" "deploy/charts/ceph-csi-drivers/Chart.yaml"
46+
47+
helm package deploy/charts/ceph-csi-operator -d .csi-op-release-packages
48+
helm package deploy/charts/ceph-csi-drivers -d .csi-op-release-packages
49+
50+
- name: Upload chart packages to GitHub Releases
51+
run: |
52+
echo "uploading the package to the release"
53+
cr upload \
54+
--owner=${{ github.repository_owner }} \
55+
--git-repo=ceph-csi-operator \
56+
--token=${{ secrets.CEPH_CSI_BOT_TOKEN }} \
57+
--package-path=.csi-op-release-packages
58+
59+
- name: Update Helm repo index and push to gh-pages
60+
run: |
61+
git remote set-url origin https://github.com/${{ github.repository }}.git
62+
git config user.name ${{ secrets.CEPH_CSI_BOT_USER }}
63+
git config user.email ${{ secrets.CEPH_CSI_BOT_EMAIL }}
64+
git checkout deploy/charts/ceph-csi-operator/Chart.yaml deploy/charts/ceph-csi-drivers/Chart.yaml
65+
git checkout gh-pages
66+
67+
mkdir -p .cr-index
68+
69+
cr index \
70+
--owner=${{ github.repository_owner }} \
71+
--git-repo=ceph-csi-operator \
72+
--package-path=.csi-op-release-packages \
73+
--token=${{ secrets.CSI_GITHUB_TOKEN }} \
74+
--index-path=.cr-index/index.yaml
75+
76+
77+
cp -r .cr-index/* .
78+
git add .
79+
git commit -m "Update Helm repo index from release ${{ github.event.release.tag_name }}"
80+
git push origin gh-pages -f

0 commit comments

Comments
 (0)