Skip to content

Commit

Permalink
Fix/refine-tagging-logic (#21)
Browse files Browse the repository at this point in the history
* fix: refine tagging logic

* feat: verify tag with semver

* fix: set-output deprecated

* fix: also use new envs
  • Loading branch information
Fovty authored Apr 18, 2024
1 parent 62b4bd0 commit f18cd0b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f18cd0b

Please sign in to comment.