Skip to content
Snippets Groups Projects
Commit 67d60ae7 authored by (INACTIVE) Marcel Bajdel (new marcel.bajdel)'s avatar (INACTIVE) Marcel Bajdel (new marcel.bajdel) :rocket:
Browse files

Adding artifacts for the check_image

parent c93e91e8
No related branches found
No related tags found
3 merge requests!20Release,!13Docker image branch,!12Docker image branch
stages: stages:
# List of stages for jobs, and their order of execution # List of stages for jobs, and their order of execution
- check_image - check_image # Check whether the image is already existing or not
- initial_build # builds if the image does not exist - initial_build # builds if the image does not exist
- build_main # builds when the merge request is made into main - build_main # builds when the merge request is made into main
- build_tag # builds when the tag is pushed - build_tag # builds when the tag is pushed
...@@ -15,14 +15,11 @@ check_image: ...@@ -15,14 +15,11 @@ check_image:
entrypoint: [""] entrypoint: [""]
script: script:
- crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- if crane manifest $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH; then echo DOCKER_LATEST_IMAGE_EXISTS=true; else echo DOCKER_LATEST_IMAGE_EXISTS=false; fi - if crane manifest $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH; then echo "DOCKER_LATEST_IMAGE_EXISTS=true" > docker_latest_image.txt; else echo "DOCKER_LATEST_IMAGE_EXISTS=false" > docker_latest_image.txt; fi
rules: artifacts:
- if: $CI_COMMIT_BRANCH paths:
changes: - docker_latest_image.txt
- "**/*"
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
when: never
initial_build: initial_build:
stage: initial_build stage: initial_build
image: image:
...@@ -31,6 +28,8 @@ initial_build: ...@@ -31,6 +28,8 @@ initial_build:
script: script:
# specify auths for kaniko executor # specify auths for kaniko executor
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
# Read the value of DOCKER_LATEST_IMAGE_EXISTS from the artifact
- DOCKER_LATEST_IMAGE_EXISTS=$(cat docker_latest_image.txt)
# if the image does not exist, build it # if the image does not exist, build it
- if $DOCKER_LATEST_IMAGE_EXISTS=false; then /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH; else echo "Docker image already exists"; fi - if $DOCKER_LATEST_IMAGE_EXISTS=false; then /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH; else echo "Docker image already exists"; fi
rules: # if the image is pushed into main branch, the build_main job will run rules: # if the image is pushed into main branch, the build_main job will run
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment