diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6336cf9666b537343dc4fb45be9324b55bdaf374..320e59a341c9d1963682e52123a29da316184c9f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -297,10 +297,22 @@ lava-badge: name: gcr.io/kaniko-project/executor:debug entrypoint: [""] script: + - test -n "$CI_ONIRO_REGISTRY" || ( + echo "CI_ONIRO_REGISTRY not provided. Docker registry deployment can not continue." + && exit 1 ) + - test -n "$CI_ONIRO_REGISTRY_IMAGE" || ( + echo "CI_ONIRO_REGISTRY_IMAGE not provided. Docker registry deployment can not continue." + && exit 1 ) + - test -n "$CI_ONIRO_REGISTRY_USER" || ( + echo "CI_ONIRO_REGISTRY_USER not provided. Docker registry deployment can not continue." + && exit 1 ) + - test -n "$CI_ONIRO_REGISTRY_TOKEN" || ( + echo "CI_ONIRO_REGISTRY_TOKEN not provided. Docker registry deployment can not continue." + && exit 1 ) - | set -xe mkdir -p /kaniko/.docker - printf '{"auths":{"%s":{"auth":"%s"}}}\n' "$CI_REGISTRY" "$(printf '%s:%s' "$CI_REGISTRY_USER" "$CI_REGISTRY_PASSWORD" | base64)" > /kaniko/.docker/config.json + printf '{"auths":{"%s":{"auth":"%s"}}}\n' "$CI_ONIRO_REGISTRY" "$(printf '%s:%s' "$CI_ONIRO_REGISTRY_USER" "$CI_ONIRO_REGISTRY_TOKEN" | base64)" > /kaniko/.docker/config.json BUILD_DATE="$(date '+%FT%T%z' | sed -E -n 's/(\+[0-9]{2})([0-9]{2})$/\1:\2/p')" #rfc 3339 date BUILD_TITLE=$(echo "$CI_PROJECT_TITLE" | tr " " "_") IMAGE_LABELS="$(cat <<EOM @@ -317,7 +329,7 @@ lava-badge: --label org.opencontainers.image.description=$BUILD_TITLE --label org.opencontainers.image.documentation=$CI_PROJECT_URL --label org.opencontainers.image.licenses=$CI_PROJECT_URL - --label org.opencontainers.image.ref.name=$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME + --label org.opencontainers.image.ref.name=$CI_ONIRO_REGISTRY:$CI_COMMIT_REF_NAME --label org.opencontainers.image.revision=$CI_COMMIT_SHA --label org.opencontainers.image.source=$CI_PROJECT_URL --label org.opencontainers.image.title=$BUILD_TITLE @@ -340,8 +352,8 @@ lava-badge: fi FORMATTED_TAG_LIST="$(echo "$FORMATTED_TAG_LIST" | sed -e 's/--tag/--destination/g')" - echo "Building and shipping image to $CI_REGISTRY_IMAGE" - exec /kaniko/executor --context "$CI_PROJECT_DIR/.oniro-ci/containers/$CONTAINER_PATH" --dockerfile "$CI_PROJECT_DIR/.oniro-ci/containers/$CONTAINER_PATH/Dockerfile" --destination $CI_REGISTRY_IMAGE/$CONTAINER_PATH $IMAGE_LABELS + echo "Building and shipping image to $CI_ONIRO_REGISTRY" + exec /kaniko/executor --context "$CI_PROJECT_DIR/.oniro-ci/containers/$CONTAINER_PATH" --dockerfile "$CI_PROJECT_DIR/.oniro-ci/containers/$CONTAINER_PATH/Dockerfile" --destination $CI_ONIRO_REGISTRY_IMAGE/$CONTAINER_PATH $IMAGE_LABELS rules: - if: $CI_PIPELINE_SOURCE == "schedule" when: never