Skip to content

Commit ae50966

Browse files
authored
Operator helm releases should push index to GH pages (#1481)
Summary: We want to start using Github to host our Helm charts. As a part of that process, we should update the `index.yaml` with the new helm chart entry. This PR updates the helm build release script to generate the new index file, and also updates the Github workflow to push it to the gh-pages branch. Relevant Issues: N/A Type of change: /kind cleanup Test Plan: Build an rc --------- Signed-off-by: Michelle Nguyen <michellenguyen@pixielabs.ai>
1 parent 53629eb commit ae50966

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

.github/workflows/operator_release.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ jobs:
4343
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}
4444
COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}}
4545
GOOGLE_APPLICATION_CREDENTIALS: ${{ steps.gcloud-creds.outputs.gcloud-creds }}
46+
GH_REPO: ${{ github.repository }}
4647
shell: bash
4748
run: |
4849
export TAG_NAME="${REF#*/tags/}"
4950
export ARTIFACTS_DIR="$(pwd)/artifacts"
51+
export INDEX_FILE="$(pwd)/index.yaml"
5052
mkdir -p "${ARTIFACTS_DIR}"
5153
./ci/save_version_info.sh
5254
./ci/operator_build_release.sh
@@ -65,6 +67,10 @@ jobs:
6567
with:
6668
name: operator-artifacts
6769
path: artifacts/
70+
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
71+
with:
72+
name: index-artifacts
73+
path: index.yaml
6874
create-github-release:
6975
if: ${{ !contains(github.event.ref, '-') }}
7076
name: Create Release on Github
@@ -93,4 +99,38 @@ jobs:
9399
gh release create "${TAG_NAME}" --title "Operator ${TAG_NAME#release/operator/}" \
94100
--notes $'Pixie Operator Release:\n'"${changelog}"
95101
gh release upload "${TAG_NAME}" operator-artifacts/*
102+
create-helm-chart:
103+
if: ${{ !contains(github.event.ref, '-') }}
104+
name: Create Helm chart on Github
105+
runs-on: ubuntu-latest
106+
needs: build-release
107+
concurrency: gh-pages
108+
permissions:
109+
contents: write
110+
steps:
111+
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
112+
with:
113+
fetch-depth: 0
114+
ref: gh-pages
115+
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
116+
- name: Setup git
117+
shell: bash
118+
env:
119+
GIT_SSH_COMMAND: "ssh -i /tmp/ssh.key"
120+
run: |
121+
git config --global user.name 'pixie-io-buildbot'
122+
git config --global user.email 'build@pixielabs.ai'
123+
- name: Push Helm YAML to gh-pages
124+
shell: bash
125+
env:
126+
TAG_NAME: ${{ github.event.release.tag_name }}
127+
GH_TOKEN: ${{ secrets.BUILDBOT_GH_API_TOKEN }}
128+
GIT_SSH_COMMAND: "ssh -i /tmp/ssh.key"
129+
# yamllint disable rule:indentation
130+
run: |
131+
cp index-artifacts/index.yaml helm_chart/index.yaml
132+
git add helm_chart/index.yaml
133+
export VERSION="$(echo "${TAG_NAME}" | cut -d'/' -f3)"
134+
git commit -s -m "Release Helm chart ${VERSION}"
135+
git push origin "gh-pages"
96136
# yamllint enable rule:indentation

ci/operator_helm_build_release.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ parse_args() {
3434
parse_args "$@"
3535
tmp_dir="$(mktemp -d)"
3636
artifacts_dir="${ARTIFACTS_DIR:?}"
37+
index_file="${INDEX_FILE:?}"
38+
gh_repo="${GH_REPO:?}"
3739

3840
helm_gcs_bucket="pixie-operator-charts"
3941
if [[ $VERSION == *"-"* ]]; then
@@ -88,3 +90,12 @@ cp sha "${artifacts_dir}/pixie-operator-chart-${VERSION}.tgz.sha256"
8890

8991
# Upload the new index and tar to gcs by syncing. This will help keep the timestamps for pre-existing tars the same.
9092
gsutil rsync "${tmp_dir}/${helm_gcs_bucket}" "gs://${helm_gcs_bucket}"
93+
94+
# Generate separate index file for GH.
95+
mkdir -p "${tmp_dir}/gh_helm_chart"
96+
helm package "${helm_path}" -d "${tmp_dir}/gh_helm_chart"
97+
# Pull index file.
98+
curl https://artifacts.px.dev/helm_chart/index.yaml -o old_index.yaml
99+
# Update the index file.
100+
helm repo index "${tmp_dir}/gh_helm_chart" --merge old_index.yaml --url "https://github.com/${gh_repo}/releases/download/release%2Foperator%2Fv${VERSION}"
101+
mv "${tmp_dir}/gh_helm_chart/index.yaml" "${index_file}"

0 commit comments

Comments
 (0)