Skip to content
Snippets Groups Projects
Verified Commit 5675a04b authored by Mustafa Soylu's avatar Mustafa Soylu
Browse files

build for all, push image for merge and deploy only on merge

parent c2a6899d
No related branches found
No related tags found
No related merge requests found
Pipeline #513566 passed
......@@ -24,19 +24,18 @@ build_dev:
# Build the image with the SHA-specific tag
- docker build --build-arg SERVER_URL="https://docs.dev.unhide.helmholtz-metadaten.de/" --build-arg NODE_ENV=dev -t "$IMAGE_NAME_SHA" .
# Tag the image as 'develop:latest'
- docker tag "$IMAGE_NAME_SHA" "$IMAGE_NAME"
# Push both tags
- docker push "$IMAGE_NAME_SHA"
- docker push "$IMAGE_NAME"
# Save IMAGE_NAME_SHA to a file
- echo "$IMAGE_NAME_SHA" > image_name_sha.txt
# Only push the image if it's a direct commit to `dev`
- |
if [ "$CI_COMMIT_BRANCH" == "dev" ] && [ "$CI_PIPELINE_SOURCE" == "push" ]; then
docker tag "$IMAGE_NAME_SHA" "$IMAGE_NAME"
docker push "$IMAGE_NAME_SHA"
docker push "$IMAGE_NAME"
echo "$IMAGE_NAME_SHA" > image_name_sha.txt
fi
artifacts:
paths:
- image_name_sha.txt
expire_in: 1 hour # Optional: Set how long the artifact is kept
expire_in: 1 hour
rules:
- if: '$CI_COMMIT_BRANCH == "dev"'
exists:
......@@ -50,7 +49,7 @@ update_manifests_dev:
variables:
MANIFESTS_REPO: 'https://codebase.helmholtz.cloud/hmc/hmc-public/unhide/development/devops/documentation-manifests.git'
dependencies:
- build_dev # Ensure the artifact is downloaded from the build_dev job
- build_dev
before_script:
- git config --global user.name "GitLab CI"
- git config --global user.email "ci@backend.manifests"
......@@ -74,7 +73,6 @@ update_manifests_dev:
- git commit -m "Update image to $IMAGE_NAME_SHA"
- git push
artifacts:
expire_in: 1 hour # Optional: Set artifact expiration for the sync job
expire_in: 1 hour
rules:
- if: '$CI_COMMIT_BRANCH == "dev"'
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "dev"'
- if: '$CI_COMMIT_BRANCH == "dev" && $CI_PIPELINE_SOURCE == "push"'
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