Split build job for branches and tags

Use CI_COMMIT_TAG for tag builds to preserve original tag format (v0.0.1 instead of v0-0-1)
This commit is contained in:
Sergey Paramoshkin 2026-02-01 00:16:38 +03:00
parent 4945897e8c
commit a3febe3f2d
1 changed files with 11 additions and 1 deletions

View File

@ -24,7 +24,8 @@ variables:
before_script:
- echo "${REGISTRY_PASSWORD}" | docker login ${REGISTRY} -u ${REGISTRY_USER} --password-stdin
build:
# Сборка веток
build:branch:
extends: .docker-build
stage: build
script:
@ -32,4 +33,13 @@ build:
- docker push ${IMAGE_NAME}:${CI_COMMIT_REF_SLUG}
rules:
- if: $CI_COMMIT_BRANCH
# Сборка тегов (v0.0.1 → registry/app:v0.0.1)
build:tag:
extends: .docker-build
stage: build
script:
- docker build --pull -f ${DOCKERFILE} -t ${IMAGE_NAME}:${CI_COMMIT_TAG} ${DOCKER_CONTEXT}
- docker push ${IMAGE_NAME}:${CI_COMMIT_TAG}
rules:
- if: $CI_COMMIT_TAG