.github/workflows/helm-charts-release.yaml
# SPDX-FileCopyrightText: the secureCodeBox authors
#
# SPDX-License-Identifier: Apache-2.0
# The CI runs on ubuntu-22.04; More info about the installed software is found here:
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md
on:
release:
types: [published]
name: "Publish Helm Charts"
jobs:
helm:
name: Package and Publish
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: "Install yq"
run: |
sudo snap install yq
- name: "Publish Helm Charts"
env:
HELM_REGISTRY: https://charts.securecodebox.io
USERNAME: ${{ secrets.HELM_REGISTRY_USERNAME }}
PASSWORD: ${{ secrets.HELM_REGISTRY_PASSWORD }}
run: |
RELEASE_VERSION="${GITHUB_REF#refs/*/}"
# Remove leading 'v' from git tag to create valid semver
RELEASE_VERSION="${RELEASE_VERSION//v}"
# Publish all helm charts in all folders containing a `Chart.yaml` file
# https://github.com/koalaman/shellcheck/wiki/SC2044
find . -type f -name Chart.yaml -not -path "./.templates/*" -print0 | while IFS= read -r -d '' chart; do
(
dir="$(dirname "${chart}")"
cd "${dir}" || exit
echo "Processing Helm Chart in $dir"
NAME=$(yq eval '.name' - < Chart.yaml)
if [ -d "docs" ]; then
echo "Docs Folder found at: ${dir}/docs"
# Use prepared ArtifactHub specific README instead of the general existing one
cp docs/README.ArtifactHub.md README.md
else
echo "Ignoring Docs process for Chart $dir, because no `docs` folder found at: ${dir}/docs"
fi
helm package --version $RELEASE_VERSION .
curl --silent --show-error --http1.1 --user "${USERNAME}:${PASSWORD}" --data-binary "@${NAME}-${RELEASE_VERSION}.tgz" "${HELM_REGISTRY}/api/charts"
sleep 5s
)
done