From f18cd0bba2de081668fbc3494a74af3465668461 Mon Sep 17 00:00:00 2001 From: Johannes <38868829+Fovty@users.noreply.github.com> Date: Thu, 18 Apr 2024 22:47:45 +0200 Subject: [PATCH] Fix/refine-tagging-logic (#21) * fix: refine tagging logic * feat: verify tag with semver * fix: set-output deprecated * fix: also use new envs --- .github/workflows/docker-build.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 14231a8..d4f01f2 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -11,18 +11,28 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Check Version Format in Tag + if: startsWith(github.ref, 'refs/tags/v') + uses: nowsprinting/check-version-format-action@v4.0.2 + id: check-version + with: + prefix: 'v' + - name: Set tag id: set-tag run: | SHORT_SHA=$(git rev-parse --short HEAD) - if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then - echo "::set-output name=tag1::latest" - echo "::set-output name=tag2::commit-$SHORT_SHA" - else - echo "::set-output name=tag1::dev" - echo "::set-output name=tag2::commit-$SHORT_SHA" + TAG1="dev" + TAG2="commit-$SHORT_SHA" + + if [[ "${{ steps.check-version.outputs.is_valid }}" == 'true' ]]; then + TAG1="latest" + TAG2="${{ steps.check-version.outputs.full_without_prefix }}" fi + echo "TAG1=$TAG1" >> $GITHUB_ENV + echo "TAG2=$TAG2" >> $GITHUB_ENV + - name: Docker meta id: meta uses: docker/metadata-action@v5 @@ -31,8 +41,8 @@ jobs: mtr.devops.telekom.de/caas/py-kube-downscaler ghcr.io/caas-team/py-kube-downscaler tags: | - ${{ steps.set-tag.outputs.tag1 }} - ${{ steps.set-tag.outputs.tag2 }} + ${{ env.TAG1 }} + ${{ env.TAG2 }} - name: Install Cosign uses: sigstore/cosign-installer@main