Files
charts/.github/workflows/publish-charts.yml
Ultradesu d8ae50ac17
Some checks failed
Publish Helm Charts / detect-charts (push) Failing after 3s
Publish Helm Charts / lint-test (push) Has been skipped
Publish Helm Charts / publish (push) Has been skipped
Publish Helm Charts / summary (push) Successful in 1s
Added CI
2026-02-04 14:40:22 +02:00

150 lines
4.7 KiB
YAML

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:
detect-charts:
runs-on: ubuntu-latest
outputs:
charts: ${{ steps.list_charts.outputs.charts }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect charts
id: list_charts
run: |
CHARTS=()
# Find all directories with Chart.yaml in root
for dir in */; do
if [ -f "${dir}Chart.yaml" ]; then
CHARTS+=("${dir%/}")
fi
done
# Convert to JSON array
CHARTS_JSON=$(printf '%s\n' "${CHARTS[@]}" | jq -R . | jq -s .)
echo "charts=$CHARTS_JSON" >> $GITHUB_OUTPUT
echo "Found charts: ${CHARTS[*]}"
lint-test:
needs: detect-charts
runs-on: ubuntu-latest
if: 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
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
echo "⚠️ Chart ${{ matrix.chart }} not found in registry index yet"
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"