Adding workflow and script to build helm chart.

This commit is contained in:
3uzbcqje
2026-02-16 19:08:36 -08:00
committed by maximilien
parent 05e294307e
commit b41e0f49bf
2 changed files with 64 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
steps:
helm:
when:
- event: pull_request
branch: main
- event: push
branch: main
image: alpine/helm:4.1.1
environment:
helm_registry: codeberg.org
helm_username: ${CI_REPO_OWNER}
# To create helm_password:
# 1. Go to https://codeberg.org/user/settings/applications.
# 2. Create a token with these settings:
# - Token name: https://git.deuxfleurs.fr/3uzbcqje/garage/src/branch/main-v2/.woodpecker/helm.yaml
# - Set package permission to "Read and write".
# 3. Click "Generate token".
# 4. Copy the token.
# 5. Log into https://ci.codeberg.org.
# 6. Find your repo, and add a secret with these settings:
# - Name: helm_password
# - Value: <the token you copied earlier>
# 7. Click "Add secret".
helm_password:
from_secret: helm_password
git_repo_owner: ${CI_REPO_OWNER}
commands:
- |
if [[ "${CI_PIPELINE_EVENT}" == "push" && "${CI_COMMIT_BRANCH}" == "main" ]]; then
./pipeline.sh push
else
./pipeline.sh
fi
Executable
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
# Not using "-x" because we aren't debugging.
set -Eeuo pipefail
# We get unbound var err if we don't set arg
arg="${1:-}"
echo "$helm_password" | helm registry login -u "$helm_username" --password-stdin "$helm_registry"
helm lint "script/helm/garage"
for chart in "script/helm/garage"; do
chart_name=$(echo "$chart" | cut -d/ -f2)
chart_version=$(grep '^version: ' "${chart}/Chart.yaml" | cut -d' ' -f 2)
helm package "${chart}"
# If chart already exists in the chart repository, don't push.
if helm pull "oci://${helm_registry}/${git_repo_owner}/charts/${chart_name}" --version "${chart_version}" &> /dev/null; then
echo -e "\e[31mWARNING: Chart ${chart_name} version ${chart_version} already exists in the repository.\nThis means that the chart's code has not changed, or you forgot to update the version in Chart.yaml.\e[0m"
else
if [[ $arg == 'push' ]]; then
helm push "${chart_name}-${chart_version}.tgz" "oci://${helm_registry}/${git_repo_owner}/charts"
fi
fi
done