Added CI
Some checks failed
Publish Helm Charts / build-and-publish (push) Failing after 4s

This commit is contained in:
Ultradesu
2026-02-04 14:45:39 +02:00
parent 3c972b82fd
commit 813139432b

View File

@@ -11,152 +11,100 @@ env:
GITEA_OWNER: ab GITEA_OWNER: ab
jobs: jobs:
detect-charts: build-and-publish:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
charts: ${{ steps.list_charts.outputs.charts }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Detect charts - name: Set up Helm
id: list_charts uses: azure/setup-helm@v4
with:
version: v3.14.0
- name: Find and process charts
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: | run: |
CHARTS=() echo "🔍 Searching for Helm charts..."
CHARTS_FOUND=0
# Find all directories with Chart.yaml in root # Find all directories with Chart.yaml in root
for dir in */; do for dir in */; do
if [ -f "${dir}Chart.yaml" ]; then if [ -f "${dir}Chart.yaml" ]; then
CHARTS+=("${dir%/}") 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 "$GITEA_TOKEN" ]; then
echo "Publishing $CHART_FILE to registry..."
HTTP_CODE=$(curl -w "%{http_code}" -s -o /dev/null \
-H "Authorization: token $GITEA_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 -s -H "Authorization: token $GITEA_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 "⚠️ GITEA_TOKEN not set, skipping publication"
fi
else
echo " Skipping publication (not on main/master branch)"
fi
CHARTS_FOUND=$((CHARTS_FOUND + 1))
fi fi
done done
echo "Found charts: ${CHARTS[*]}" if [ $CHARTS_FOUND -eq 0 ]; then
echo "❌ No Helm charts found in repository root"
# Convert to JSON array manually for compatibility
if [ ${#CHARTS[@]} -eq 0 ]; then
echo "charts=[]" >> $GITHUB_OUTPUT
else
CHARTS_JSON="["
for i in "${!CHARTS[@]}"; do
if [ $i -gt 0 ]; then
CHARTS_JSON="${CHARTS_JSON},"
fi
CHARTS_JSON="${CHARTS_JSON}\"${CHARTS[$i]}\""
done
CHARTS_JSON="${CHARTS_JSON}]"
echo "charts=${CHARTS_JSON}" >> $GITHUB_OUTPUT
fi
lint-test:
needs: detect-charts
runs-on: ubuntu-latest
if: needs.detect-charts.outputs.charts != '[]' && needs.detect-charts.outputs.charts != ''
strategy:
matrix:
chart: ${{ fromJSON(needs.detect-charts.outputs.charts) }}
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: Lint chart - ${{ matrix.chart }}
run: |
echo "Linting chart: ${{ matrix.chart }}"
helm lint ${{ matrix.chart }}/
- name: Template test - ${{ matrix.chart }}
run: |
echo "Template testing chart: ${{ matrix.chart }}"
helm template test ${{ matrix.chart }}/ --debug
publish:
needs: [detect-charts, lint-test]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
strategy:
matrix:
chart: ${{ fromJSON(needs.detect-charts.outputs.charts) }}
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: Get chart info - ${{ matrix.chart }}
id: chart_info
run: |
VERSION=$(helm show chart ${{ matrix.chart }}/ | grep '^version:' | awk '{print $2}')
NAME=$(helm show chart ${{ matrix.chart }}/ | grep '^name:' | awk '{print $2}')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "name=$NAME" >> $GITHUB_OUTPUT
echo "Chart: $NAME, Version: $VERSION"
- name: Create packages directory
run: mkdir -p packages
- name: Package chart - ${{ matrix.chart }}
run: |
echo "Packaging chart: ${{ matrix.chart }}"
helm package ${{ matrix.chart }}/ --destination ./packages/
- name: Publish to Gitea Registry - ${{ matrix.chart }}
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
CHART_FILE="packages/${{ steps.chart_info.outputs.name }}-${{ steps.chart_info.outputs.version }}.tgz"
echo "Publishing chart: $CHART_FILE"
response=$(curl -w "%{http_code}" -s -H "Authorization: token $GITEA_TOKEN" \
-X POST \
--upload-file "$CHART_FILE" \
"$GITEA_URL/api/packages/$GITEA_OWNER/helm/api/charts")
if [[ "$response" =~ ^2[0-9][0-9]$ ]]; then
echo "✅ Chart ${{ matrix.chart }} published successfully!"
else
echo "❌ Failed to publish chart ${{ matrix.chart }}. HTTP status: $response"
exit 1 exit 1
fi
- name: Verify publication - ${{ matrix.chart }}
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
echo "Checking if chart ${{ matrix.chart }} is available in registry..."
# Wait for indexing
sleep 10
if curl -s -H "Authorization: token $GITEA_TOKEN" \
"$GITEA_URL/api/packages/$GITEA_OWNER/helm/index.yaml" \
| grep -q "${{ steps.chart_info.outputs.name }}-${{ steps.chart_info.outputs.version }}"; then
echo "✅ Chart ${{ matrix.chart }} verified in registry!"
else else
echo "⚠️ Chart ${{ matrix.chart }} not found in registry index yet" echo "📊 Summary: Processed $CHARTS_FOUND chart(s)"
fi echo "🌐 Registry: $GITEA_URL/packages/$GITEA_OWNER"
fi
summary:
needs: [detect-charts, publish]
runs-on: ubuntu-latest
if: always() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
steps:
- name: Summary
run: |
echo "📦 Helm Charts Publication Summary"
echo "Charts processed: ${{ join(fromJSON(needs.detect-charts.outputs.charts), ', ') }}"
echo "Registry: $GITEA_URL/packages/$GITEA_OWNER"