ci: tag container image release (#407)

Co-authored-by: Kunal Singh <kunalsin9h@gmail.com>
This commit is contained in:
Abhisek Datta 2025-03-21 16:13:51 +05:30 committed by GitHub
parent c1d9050d26
commit 4be215d914
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,7 +18,7 @@ env:
jobs:
build:
if: "!contains(github.event.commits[0].message, '[noci]')"
if: '!contains(github.event.commits[0].message, "[noci]")'
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
@ -47,8 +47,31 @@ jobs:
- name: Build and Push Container Image
run: |
docker buildx build --push --platform linux/amd64 --platform linux/arm64 \
-t $REGISTRY/$IMAGE_NAME:latest \
.
# Get the tag if this was a tag push event
if [[ "${{ github.ref_type }}" == "tag" ]]; then
TAG=${{ github.ref_name }}
# Validate tag format (must be vX.Y.Z)
if [[ $TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Build and push with both version tag and latest
docker buildx build --push --platform linux/amd64,linux/arm64 \
-t $REGISTRY/$IMAGE_NAME:$TAG \
-t $REGISTRY/$IMAGE_NAME:latest \
.
else
echo "Invalid tag format. Must be in format vX.Y.Z (e.g. v1.2.3)"
exit 1
fi
else
# For non-tag pushes, just use latest tag
docker buildx build --push --platform linux/amd64,linux/arm64 \
-t $REGISTRY/$IMAGE_NAME:latest \
.
fi
- uses: actions/delete-package-versions@e5bc658cc4c965c472efe991f8beea3981499c55 # v5.0.0
name: Remove Old Container Images
with:
package-name: vet
package-type: 'container'
delete-only-untagged-versions: 'true'