From 5520b6f07567bd68c821738c8e45f9ed44cd39fc Mon Sep 17 00:00:00 2001 From: TannerGabriel Date: Wed, 6 Jul 2022 15:38:53 +0200 Subject: [PATCH] feat: Use helm build action (#305) * chore: Remove kubernetes-utils dependency Signed-off-by: TannerGabriel * feat: Use Helm build action Signed-off-by: TannerGabriel * Use CHART_NAME instead of IMAGE Signed-off-by: TannerGabriel --- .dockerignore | 1 - .github/workflows/CI.yml | 6 ++- .github/workflows/pre-release.yml | 6 ++- .github/workflows/release.yml | 6 ++- gh-actions-scripts/build_helm_chart.sh | 53 -------------------------- 5 files changed, 15 insertions(+), 57 deletions(-) delete mode 100755 gh-actions-scripts/build_helm_chart.sh diff --git a/.dockerignore b/.dockerignore index be0d2123..51b34768 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,4 +11,3 @@ bin/ test-data/ test-events/ assets/ -gh-actions-scripts/ diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7606c651..834ff18f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -189,7 +189,11 @@ jobs: - name: Build Helm Charts id: build_helm_charts - run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}.${DATETIME}" "${IMAGE}" + uses: keptn/gh-automation/.github/actions/build-helm-charts@v1.6.0 + with: + VERSION: ${{ env.VERSION }} + APP_VERSION: ${{ env.VERSION }}.${{ env.DATETIME }} + CHART_NAME: ${{ env.IMAGE }} - name: Upload Helm Chart as an artifact id: upload_helm_chart diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 29b15e43..97ca5c1d 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -74,7 +74,11 @@ jobs: - name: Build Helm Charts id: build_helm_charts - run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}" + uses: keptn/gh-automation/.github/actions/build-helm-charts@v1.6.0 + with: + VERSION: ${{ env.VERSION }} + APP_VERSION: ${{ env.VERSION }} + CHART_NAME: ${{ env.IMAGE }} - name: Upload Helm Chart as release asset env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4d126fa5..0eef1094 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -74,7 +74,11 @@ jobs: - name: Build Helm Charts id: build_helm_charts - run: ./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}" + uses: keptn/gh-automation/.github/actions/build-helm-charts@v1.6.0 + with: + VERSION: ${{ env.VERSION }} + APP_VERSION: ${{ env.VERSION }} + CHART_NAME: ${{ env.IMAGE }} - name: Upload Helm Chart as release asset env: diff --git a/gh-actions-scripts/build_helm_chart.sh b/gh-actions-scripts/build_helm_chart.sh deleted file mode 100755 index af382391..00000000 --- a/gh-actions-scripts/build_helm_chart.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC2181 - -VERSION=$1 # e.g., 0.7.2-next.0 -APP_VERSION=$2 # e.g., 0.7.2-next.0+1234 -IMAGE=$3 # e.g., job-executor-service - -if [ $# -ne 3 ]; then - echo "Usage: $0 VERSION APP_VERSION IMAGE" - exit -fi - -if [ -z "$VERSION" ]; then - echo "No Version set, exiting..." - exit 1 -fi - -if [ -z "$APP_VERSION" ]; then - echo "No Image Tag set, defaulting to version" - APP_VERSION=$VERSION -fi - - -# replace "appVersion: latest" with "appVersion: $VERSION" in all Chart.yaml files -# find . -name Chart.yaml -exec sed -i -- "s/appVersion: latest/appVersion: ${APP_VERSION}/g" {} \; -# find . -name Chart.yaml -exec sed -i -- "s/version: latest/version: ${VERSION}/g" {} \; - -mkdir -p installer/ - -# #################### -# HELM CHART -# #################### -BASE_PATH=. -CHARTS_PATH=chart - -# lint the chart -helm lint ${BASE_PATH}/${CHARTS_PATH} --strict -if [ $? -ne 0 ]; then - echo "::error Helm Chart for ${IMAGE} has templating errors -exiting" - exit 1 -fi - -# package the chart -helm package ${BASE_PATH}/${CHARTS_PATH} --app-version "$APP_VERSION" --version "$VERSION" -if [ $? -ne 0 ]; then - echo "Error packaging installer, exiting..." - exit 1 -fi - -mv "${IMAGE}-${VERSION}.tgz" "installer/${IMAGE}-${VERSION}.tgz" - -echo "Generated files:" -echo " - installer/${IMAGE}-${VERSION}.tgz"