Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Documentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Helmholtz Metadata Collaboration
HMC Public
unHIDE
Documentation
Commits
1391f4c3
Verified
Commit
1391f4c3
authored
3 weeks ago
by
Mustafa Soylu
Browse files
Options
Downloads
Patches
Plain Diff
update gitlab ci
parent
3ce83e0c
No related branches found
Branches containing commit
No related tags found
1 merge request
!15
k8s deployment
Pipeline
#513223
failed
3 weeks ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+67
-14
67 additions, 14 deletions
.gitlab-ci.yml
with
67 additions
and
14 deletions
.gitlab-ci.yml
+
67
−
14
View file @
1391f4c3
stages
:
-
build
-
deploy
-
sync
docs-build
:
# Job for building and pushing Docker image for the development environment
build_dev
:
image
:
docker:stable
stage
:
build
image
:
node:20
tags
:
-
docker
services
:
-
name
:
docker:27.3.1-dind
alias
:
docker
variables
:
DOCKER_IMAGE_BASE
:
"
$CI_REGISTRY_IMAGE"
# Base image name without a tag
DOCKER_IMAGE_TAG
:
"
develop"
# Tag for this branch
before_script
:
-
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script
:
-
npm install
-
npm run build
# Full image name with tag
-
IMAGE_NAME="$DOCKER_IMAGE_BASE:$DOCKER_IMAGE_TAG"
-
IMAGE_NAME_SHA="$DOCKER_IMAGE_BASE:$DOCKER_IMAGE_TAG-$CI_COMMIT_SHA"
# Build the image with the SHA-specific tag
-
docker build -build-arg SERVER_URL="$SERVER_URL" --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
artifacts
:
paths
:
-
build
-
image_name_sha.txt
expire_in
:
1 hour
# Optional: Set how long the artifact is kept
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
==
"develop"
or
$CI_COMMIT_BRANCH
==
"18-k8s-deployment"'
# temporary or
exists
:
-
Dockerfile
# Update backend-manifests repository with the new image tag
update_manifests_dev
:
image
:
bitnami/git:latest
stage
:
sync
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
before_script
:
-
git config --global user.name "GitLab CI"
-
git config --global user.email "ci@backend.manifests"
-
git config --global credential.helper 'store --file=/tmp/git-credentials'
-
echo "https://$DEPLOY_TOKEN_USERNAME:$DEPLOY_TOKEN_PASSWORD@codebase.helmholtz.cloud" > /tmp/git-credentials
# Retrieve the IMAGE_NAME_SHA from the artifact
-
IMAGE_NAME_SHA=$(cat image_name_sha.txt)
-
echo "Using IMAGE_NAME_SHA=$IMAGE_NAME_SHA"
pages
:
stage
:
deploy
image
:
busybox:latest
needs
:
[
docs-build
]
script
:
-
mv build public
# Clone the repository
-
git clone "$MANIFESTS_REPO" backend-manifests
-
cd documentation-manifests/dev
# Update the image tag in the deployment manifest
-
'
sed
-i
"s|image:
.*|image:
$IMAGE_NAME_SHA|g"
deployment.yaml'
# Commit and push changes
-
git add deployment.yaml
-
git commit -m "Update image to $IMAGE_NAME_SHA"
-
git push
artifacts
:
paths
:
-
public
expire_in
:
1 hour
# Optional: Set artifact expiration for the sync job
rules
:
-
if
:
$CI_COMMIT_BRANCH == "
main"
-
if
:
'
$CI_COMMIT_BRANCH
==
"
develop"'
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment