kind: pipeline type: kubernetes name: update-helm-charts steps: # Step 1: Lint all Helm charts - name: lint-charts image: alpine/helm:latest commands: - find charts -maxdepth 2 -type d -regex ".*/v[0-9]+\.[0-9]+\.[0-9]+" -exec helm lint {} \; # Step 2: Package only changed Helm charts - name: package-all-charts image: alpine/helm:latest commands: - mkdir -p charts/dist # Find all versioned chart directories - ALL_CHARTS=`find charts -maxdepth 2 -type d -regex '.*/v[0-9]+\.[0-9]+\.[0-9]+'` - "echo \"Detected charts: $ALL_CHARTS\"" - if [ -n "$ALL_CHARTS" ]; then echo "$ALL_CHARTS" | xargs -I {} helm package {} --destination charts/dist; else echo "No charts found in repository"; exit 1; fi # Debug: List packaged files - ls -la charts/dist/ || echo "No files in charts/dist/" depends_on: - lint-charts # Step 3: Push charts to Harbor - name: push-to-harbor image: alpine/helm:latest commands: # Fail if credentials are missing - "if [ -z \"$HARBOR_USERNAME\" ] || [ -z \"$HARBOR_PASSWORD\" ]; then echo \"Error: HARBOR_USERNAME or HARBOR_PASSWORD not set\"; exit 1; fi" # Login to Harbor registry - "helm registry login -u \"$HARBOR_USERNAME\" -p \"$HARBOR_PASSWORD\" https://porto.interlegis.leg.br" # Push each chart to Harbor (OCI format, Helm 3.8+) - for CHART in charts/dist/*.tgz; do helm push "$CHART" oci://porto.interlegis.leg.br/seit; done environment: HARBOR_USERNAME: from_secret: harbor_username HARBOR_PASSWORD: from_secret: harbor_password when: condition: ls charts/dist/*.tgz 2>/dev/null # Only run if there are new .tgz files depends_on: - package-all-charts trigger: branch: - master event: - push