From 03105a2f877b240f0b28a2c82e0753267b556388 Mon Sep 17 00:00:00 2001 From: 0xWheatyz Date: Sun, 15 Mar 2026 02:35:33 -0400 Subject: [PATCH] feat(ci): add timestamp-based image tags with commit hash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Push images with versioned tags in format TIMESTAMP-COMMIT and frontend-TIMESTAMP-COMMIT for better traceability and rollback support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .gitlab-ci.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8521da8..b90a9fe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,6 @@ stages: variables: DOCKER_DRIVER: overlay2 DOCKER_TLS_CERTDIR: "/certs" - IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG LATEST_TAG: $CI_REGISTRY_IMAGE:latest build-and-push: @@ -15,14 +14,23 @@ build-and-push: before_script: - echo "Logging into GitLab Container Registry..." - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + # Generate timestamp and short commit hash for tags + - export TIMESTAMP=$(date -u +%Y%m%d%H%M%S) + - export SHORT_COMMIT=$(echo $CI_COMMIT_SHA | cut -c1-7) + - export VERSIONED_TAG=$CI_REGISTRY_IMAGE:${TIMESTAMP}-${SHORT_COMMIT} + - export FRONTEND_TAG=$CI_REGISTRY_IMAGE:frontend-${TIMESTAMP}-${SHORT_COMMIT} script: - echo "Building Docker image..." - - docker build -t $IMAGE_TAG -t $LATEST_TAG . + - docker build -t $VERSIONED_TAG -t $FRONTEND_TAG -t $LATEST_TAG . - echo "Pushing Docker image to registry..." - - docker push $IMAGE_TAG + - docker push $VERSIONED_TAG + - docker push $FRONTEND_TAG - docker push $LATEST_TAG - echo "Build and push completed successfully!" - - echo "Image available at $IMAGE_TAG" + - echo "Images available at:" + - echo " $VERSIONED_TAG" + - echo " $FRONTEND_TAG" + - echo " $LATEST_TAG" rules: - if: $CI_COMMIT_BRANCH == "main" when: always