better image tagging in helmfile

This commit is contained in:
Robert Schäfer 2024-10-27 21:24:36 +01:00
parent d2a56c4334
commit 67cfcc9590
3 changed files with 8 additions and 2 deletions

View File

@ -83,9 +83,10 @@ jobs:
mkdir -p ~/.kube
sops decrypt ./helmfile/secrets/kubeconfig > ~/.kube/config
chmod 600 ~/.kube/config
- run: echo "IMAGE_TAG=ocelot-${{ inputs.ocelot_version }}--branded-sha-$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
- uses: helmfile/helmfile-action@80fbb6408b98822310f94d8d1321a2cacf87f78f #v1.9.2
with:
env:
OCELOT_IMAGE_TAG: ${{ inputs.ocelot_version }}
helmfile-args: apply
helmfile-workdirectory: ./helmfile
helm-plugins: >

View File

@ -1,3 +1,6 @@
{{ $branded_image_tag:= env "BRANDED_IMAGE_TAG" | default (exec "../scripts/image_tag.sh" (list) | trim) }}
{{ $ocelot_image_tag := env "OCELOT_IMAGE_TAG" | default "master" }}
domain: staging.ocelot-social.roschaefer.de
namespace: ocelot-staging
image_tag: {{ requiredEnv "IMAGE_TAG" }}
image_tag: {{ env "IMAGE_TAG" | default (printf "ocelot-%s--branded-%s" $ocelot_image_tag $branded_image_tag) }}

2
helmfile/scripts/image_tag.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
echo "sha-$(git rev-parse HEAD | cut -c 1-7)"