From 048e0d0b6aaabfd709d5c00e13a4c421ac679c58 Mon Sep 17 00:00:00 2001 From: Kieran Matheson Date: Tue, 25 Feb 2025 10:00:08 +0000 Subject: [PATCH] fix: fix image building and release process in ci --- .gitlab-ci.yml | 48 +++++++++++++++++++++++++++++++++-------- .pre-commit-config.yaml | 2 +- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e0f4d09..3fbbb54 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,8 +3,7 @@ include: inputs: tag: $CI_COMMIT_SHA -build-and-push-docker-image: - stage: .pre +.build-config: image: docker:24.0.2 services: - name: docker:24.0.2-dind @@ -15,16 +14,25 @@ build-and-push-docker-image: DOCKER_TLS_VERIFY: "true" DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client" HEALTHCHECK_TCP_PORT: "2376" - script: + TAG: "$CI_COMMIT_SHA" + before_script: - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin - - echo "CI_REGISTRY_IMAGE - $CI_REGISTRY_IMAGE" - - echo "CI_COMMIT_SHA - $CI_COMMIT_SHA" - - echo "Building and pushing image." - - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA -f templates/Dockerfile . - - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + +build-and-publish-image-sha: + stage: .pre + extends: .build-config + variables: + TAG: "$CI_COMMIT_SHA" + script: + - echo "Building Docker image..." + - docker build -t $CI_REGISTRY_IMAGE:$TAG -f templates/Dockerfile . + - echo "Pushing Image $CI_REGISTRY_IMAGE:$TAG" + - docker push $CI_REGISTRY_IMAGE:$TAG lint: extends: .pre-commit + needs: + - build-and-publish-image-sha semantic-release: stage: deploy @@ -45,4 +53,26 @@ semantic-release: rules: - if: $CI_COMMIT_TAG when: never - - if: $CI_COMMIT_REF_PROTECTED == "true" \ No newline at end of file + - if: $CI_COMMIT_REF_PROTECTED == "true" + +build-and-publish-image-version: + extends: .build-config + stage: deploy + variables: + TAG: "$CI_COMMIT_TAG" + script: + - echo "Pushing Image $CI_REGISTRY_IMAGE:$TAG" + - docker push $CI_REGISTRY_IMAGE:$TAG + rules: + - if: $CI_COMMIT_TAG + +build-and-publish-image-latest: + extends: .build-config + stage: deploy + variables: + TAG: "latest" + script: + - echo "Pushing Image $CI_REGISTRY_IMAGE:$TAG" + - docker push $CI_REGISTRY_IMAGE:$TAG + rules: + - if: $CI_COMMIT_BRANCH == "stable" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c81071..79eb6e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ default_install_hook_types: - pre-commit repos: - repo: https://gitlab.gpu.arm.com/pre-commit/hooks - rev: v2.9.1 + rev: v2.10.0 hooks: - id: check-added-large-files - id: check-filename-case-conflict -- GitLab