Commit 01b4610e authored by Dimitrios Gogos's avatar Dimitrios Gogos
Browse files

Merge branch 'develop' into 'main'

fix(ci): build and push the images for release tags

See merge request !4
parents 77f8f7ba c717d860
Loading
Loading
Loading
Loading
Loading
+6 −3
Changes for .gitlab-ci.yml: 6 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
#   $CI_REGISTRY_IMAGE/data-lab-api:ci-<branch>-<short-sha>       immutable: one per commit
#   $CI_REGISTRY_IMAGE/data-lab-api:<branch>                      moves: the latest build of that branch
#   $CI_REGISTRY_IMAGE/data-lab-admin-ui:...                      same two tags
#   $CI_REGISTRY_IMAGE/data-lab-api:<release>                     from a release tag such as 0.1.0
#
# main and develop build automatically; any other branch (for example feat/datalab) builds when the
# build-and-push job is started by hand from the pipeline page.
@@ -65,12 +66,14 @@ build-and-push:
    - docker info
  script:
    - export IMAGE="$CI_REGISTRY_IMAGE/$COMPONENT"
    - export COMMIT_TAG="ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}"
    - export COMMIT_TAG="${CI_COMMIT_TAG:-ci-${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}}"
    - export REF_TAG="${CI_COMMIT_TAG:-$CI_COMMIT_REF_SLUG}"
    - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" "$CI_REGISTRY" --password-stdin
    - docker buildx build --provenance=false --network=host -t "$IMAGE:$COMMIT_TAG" -t "$IMAGE:$CI_COMMIT_REF_SLUG" --push "$CONTEXT"
    - docker buildx build --provenance=false --network=host -t "$IMAGE:$COMMIT_TAG" -t "$IMAGE:$REF_TAG" --push "$CONTEXT"
    - docker logout "$CI_REGISTRY"
    - echo "published $IMAGE:$COMMIT_TAG and $IMAGE:$CI_COMMIT_REF_SLUG"
    - echo "published $IMAGE:$COMMIT_TAG and $IMAGE:$REF_TAG"
  rules:
    - if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
    - if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "develop"'
    - if: '$CI_COMMIT_BRANCH'
      when: manual