diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml index 25475ee..2b568c2 100644 --- a/.woodpecker/build.yaml +++ b/.woodpecker/build.yaml @@ -22,20 +22,34 @@ steps: securityContext: privileged: true - name: Push a helm chart - image: gitea.badhouseplants.net/badhouseplants/container-builder:latest + image: docker.io/alpine/helm environment: REGISTRY_TOKEN: from_secret: GITEA_REGISTRY_TOKEN privileged: true commands: - - build-container - backend_options: - kubernetes: - resources: - requests: - memory: 500Mi - cpu: 200m - limits: - memory: 500Mi - securityContext: - privileged: true + - |- + helm registry login https://gitea.badhouseplants.net \ + --password-stdin=$REGISTRY_TOKEN \ + --username=devops-bot \ + - export SHORT_SHA="+$(git rev-parse --short HEAD)" + - |- + for chart in $(find charts -maxdepth 1 -mindepth 1 -type d); do + yq e -i ".version += env(SHORT_SHA)" "$chart/Chart.yaml" + yq e -i ".appVersion = env(SHORT_SHA)" "$chart/Chart.yaml" + helm dep build $chart + helm package $chart -d chart-packages; + done + - export CHARTS=$(find chart-packages -maxdepth 1 -mindepth 1 -type f) + - export REGISTRY=$(echo oci://gitea.badhouseplants.net/$CI_REPO/helm | tr '[:upper:]' '[:lower:]') + - |- + for chart in $CHARTS; do + echo ${chart} + CHART_NAME=$(helm show chart "${chart}" | yq .name) + CHART_VERSION=$(helm show chart "${chart}" | yq .version) + if helm pull ${REGISTRY}/${CHART_NAME}:${CHART_VERSION}; then + echo "Chart is found in the upstream: ${CHART_NAME}:${CHART_VERSION}" + continue; + fi + helm push "${chart}" "${REGISTRY}" + done