Files
charts/.github/workflows/publish-charts.yml
Ultradesu 2310ad540f
Some checks failed
Publish Helm Charts / build-and-publish (push) Failing after 4s
Added CI
2026-02-04 14:50:35 +02:00

110 lines
4.0 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Publish Helm Charts
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
env:
GITEA_URL: https://gt.hexor.cy:30022
GITEA_OWNER: ab
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.14.0
- name: Find and process charts
env:
HELM_REGISTRY_TOKEN: ${{ secrets.HELM_REGISTRY_TOKEN }}
run: |
echo "🔍 Searching for Helm charts..."
CHARTS_FOUND=0
# Find all directories with Chart.yaml in root
for dir in */; do
if [ -f "${dir}Chart.yaml" ]; then
CHART_NAME="${dir%/}"
echo "📦 Found chart: $CHART_NAME"
# Lint chart
echo "🔧 Linting chart: $CHART_NAME"
helm lint "$CHART_NAME/"
# Template test
echo "🧪 Template testing chart: $CHART_NAME"
helm template test "$CHART_NAME/" --debug > /dev/null
# Get chart info
VERSION=$(helm show chart "$CHART_NAME/" | grep '^version:' | awk '{print $2}')
NAME=$(helm show chart "$CHART_NAME/" | grep '^name:' | awk '{print $2}')
echo "Chart: $NAME, Version: $VERSION"
# Only publish on main/master branch
if [[ "$GITHUB_REF" == "refs/heads/main" || "$GITHUB_REF" == "refs/heads/master" ]]; then
echo "📤 Publishing chart: $CHART_NAME"
# Create packages directory
mkdir -p packages
# Package chart
helm package "$CHART_NAME/" --destination ./packages/
CHART_FILE="packages/$NAME-$VERSION.tgz"
# Publish to Gitea Registry
if [ -n "$HELM_REGISTRY_TOKEN" ]; then
echo "Publishing $CHART_FILE to registry..."
HTTP_CODE=$(curl -k -w "%{http_code}" -s -o /dev/null \
-H "Authorization: token $HELM_REGISTRY_TOKEN" \
-X POST \
--upload-file "$CHART_FILE" \
"$GITEA_URL/api/packages/$GITEA_OWNER/helm/api/charts")
if [[ "$HTTP_CODE" =~ ^2[0-9][0-9]$ ]]; then
echo "✅ Chart $CHART_NAME published successfully! (HTTP $HTTP_CODE)"
# Verify publication
echo "🔍 Verifying publication..."
sleep 5
if curl -k -s -H "Authorization: token $HELM_REGISTRY_TOKEN" \
"$GITEA_URL/api/packages/$GITEA_OWNER/helm/index.yaml" \
| grep -q "$NAME-$VERSION"; then
echo "✅ Chart $CHART_NAME verified in registry!"
else
echo "⚠️ Chart $CHART_NAME not found in registry index yet (may take time to index)"
fi
else
echo "❌ Failed to publish chart $CHART_NAME. HTTP status: $HTTP_CODE"
exit 1
fi
else
echo "⚠️ HELM_REGISTRY_TOKEN not set, skipping publication"
fi
else
echo " Skipping publication (not on main/master branch)"
fi
CHARTS_FOUND=$((CHARTS_FOUND + 1))
fi
done
if [ $CHARTS_FOUND -eq 0 ]; then
echo "❌ No Helm charts found in repository root"
exit 1
else
echo "📊 Summary: Processed $CHARTS_FOUND chart(s)"
echo "🌐 Registry: $GITEA_URL/packages/$GITEA_OWNER"
fi