You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
2.0 KiB
52 lines
2.0 KiB
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 | grep "/v[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$" | xargs -I {} 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 | grep "/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:
|
|
# Install helm cm-push plugin
|
|
- helm plugin install https://github.com/chartmuseum/helm-push.git || true
|
|
# 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"
|
|
# Add the seit chart repository
|
|
- helm repo add seit https://porto.interlegis.leg.br/chartrepo/seit --username "$HARBOR_USERNAME" --password "$HARBOR_PASSWORD" --force-update || true
|
|
# Push all .tgz files to the seit chart repository
|
|
- if ls charts/dist/*.tgz >/dev/null 2>&1; then for CHART in charts/dist/*.tgz; do helm cm-push "$CHART" seit; done; else echo "No .tgz files to push"; exit 0; fi
|
|
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
|