From de69434ec360ffcd00172568104960df58c5ec3c Mon Sep 17 00:00:00 2001 From: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:03:17 +0100 Subject: [PATCH] feat: add helm helpers to deal with app tags --- .github/workflows/helm-build.yaml | 67 ------------------------------- helm/templates/_helpers.tpl | 7 ++++ helm/templates/deployment.yaml | 2 +- 3 files changed, 8 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/helm-build.yaml create mode 100644 helm/templates/_helpers.tpl diff --git a/.github/workflows/helm-build.yaml b/.github/workflows/helm-build.yaml deleted file mode 100644 index 65eb2c6..0000000 --- a/.github/workflows/helm-build.yaml +++ /dev/null @@ -1,67 +0,0 @@ -name: Helm Chart Build - -on: - workflow_dispatch: - push: - branches: - - "main" - - "release-*" - -concurrency: - group: helm-${{ github.ref }} - cancel-in-progress: true - -jobs: - prepare: - runs-on: ubuntu-latest - steps: - - name: Extract tag - id: extract_tag - run: | - tag=$(if [[ ${{github.ref_name}} == v* ]];then echo "${{github.ref_name}}"; else echo "latest"; fi) - echo "tag=$tag" >> $GITHUB_OUTPUT - outputs: - tag: ${{ steps.extract_tag.outputs.tag }} - - helm-build: - runs-on: ubuntu-latest - needs: - - prepare - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - distribution: "temurin" - java-version: "21" - cache: "maven" - - name: Create Helm - run: | - ## Set -Dquarkus.container-image.tag as empty to remove the "v" prefix from the container image of Deployment - mvn package -DskipTests -Dquarkus.container-image.tag= - - # YQ - sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq - sudo chmod +x /usr/bin/yq - - APP_IMAGE_TAG=$TAG yq e -i '.appVersion=strenv(APP_IMAGE_TAG)' target/helm/Chart.yaml - env: - TAG: ${{ needs.prepare.outputs.tag }} - - name: Git add Helm - id: git-add-helm - continue-on-error: true - run: | - cp -R target/helm/ ./ - - if [ -z $(git status --porcelain) ]; then - echo "has_changes=false" >> $GITHUB_OUTPUT - else - echo git status - git add helm/* - echo "has_changes=true" >> $GITHUB_OUTPUT - fi - - name: Commit and Push - uses: trustification/release-tools/.github/actions/commit@main - if: steps.git-add-helm.outputs.has_changes == 'true' - with: - commit_message: "🔅 Helm chart update" - branch: ${{github.ref_name}} \ No newline at end of file diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl new file mode 100644 index 0000000..be02936 --- /dev/null +++ b/helm/templates/_helpers.tpl @@ -0,0 +1,7 @@ +{{- define "app.tag" -}} +{{- if eq .Chart.AppVersion "latest" }} +{{- "latest" }} +{{- else }} +{{- printf "v%s" .Chart.AppVersion }} +{{- end }} +{{- end }} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index 9af7f1f..99556df 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -43,7 +43,7 @@ spec: value: "quay.io/sclorg/postgresql-15-c9s:latest" - name: "QUARKUS_OPERATOR_SDK_CONTROLLERS_TRUSTIFY_NAMESPACES" value: {{ .Values.watchNamespaces }} - image: "ghcr.io/runner/trustify-operator:{{ .Chart.AppVersion }}" + image: "ghcr.io/trustification/trustify-operator:{{ include "app.tag" . }}" imagePullPolicy: "Always" livenessProbe: failureThreshold: 3