Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/refine-tagging-logic #21

Merged
merged 4 commits into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected]
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
Loading