From 8d2a10246ba0a23254546dba57202c20094e5b84 Mon Sep 17 00:00:00 2001 From: Thatsaphorn Atchariyaphap Date: Sat, 29 Mar 2025 22:30:31 +0000 Subject: [PATCH] Merge branch 'dev' into 'production' Merge from dev See merge request rheinsw/website!15 --- .gitlab-ci.yml | 54 ++++++++++++++++++++++---------------------------- app/page.tsx | 2 +- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index affc1c8..c05d89a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,6 +24,11 @@ variables: PROJECT_NAME: $CI_PROJECT_NAME DOCKER_IMAGE: "registry.boomlab.party/rheinsw/$CI_PROJECT_NAME" +.deploy_production_rule: &deploy_production_rule + - if: $CI_COMMIT_BRANCH == "production" + when: manual + allow_failure: true + # Reusable SSH key setup block .install_deploy_key: &install_deploy_key - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' @@ -34,11 +39,6 @@ variables: - ssh-add ~/.ssh/deploy_key - ssh-keyscan -p 22 -H '192.168.41.101' >> ~/.ssh/known_hosts || true -.deploy_production_rule: &deploy_production_rule - - if: $CI_COMMIT_BRANCH == "production" - when: manual - allow_failure: true - .deploy_script: &deploy_script - | echo "Deploying $DOCKER_IMAGE:$TAG to $CONTAINER_NAME on port $PORT..." @@ -61,26 +61,30 @@ build: dockerize: stage: docker image: docker:20.10@sha256:2967f0819c84dd589ed0a023b9d25dcfe7a3c123d5bf784ffbb77edf55335f0c - services: - - docker:dind before_script: - echo "$CI_REGISTRY_PASSWORD" | docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" --password-stdin script: - | - if [[ "$CI_COMMIT_REF_NAME" == "production" ]]; then - TAG="latest" - elif [[ "$CI_COMMIT_REF_NAME" == "dev" ]]; then - TAG="dev" - else - echo "Skipping Docker build for branch $CI_COMMIT_REF_NAME" - exit 0 - fi - echo "Using tag: $TAG" + TAG="$CI_COMMIT_REF_NAME" + echo "Building Docker image with tag: $TAG" docker build -t $DOCKER_IMAGE:$TAG -f Dockerfile . - docker push $DOCKER_IMAGE:$TAG - only: - - dev - - production + + if [[ "$TAG" == "dev" || "$TAG" == "production" ]]; then + echo "Pushing Docker image $DOCKER_IMAGE:$TAG" + docker push $DOCKER_IMAGE:$TAG + else + echo "Skipping Docker push for non-dev or production branch: $TAG" + fi + +deploy_production: + stage: deploy + rules: *deploy_production_rule + before_script: *install_deploy_key + script: + - TAG="production" + - PORT="4100" + - CONTAINER_NAME="$CI_PROJECT_NAME-production" + - *deploy_script deploy_dev: stage: deploy @@ -93,16 +97,6 @@ deploy_dev: only: - dev -deploy_production: - stage: deploy - rules: *deploy_production_rule - before_script: *install_deploy_key - script: - - TAG="latest" - - PORT="4100" - - CONTAINER_NAME="$CI_PROJECT_NAME-production" - - *deploy_script - sync_branches: stage: sync rules: diff --git a/app/page.tsx b/app/page.tsx index 88f0cc9..13b3b2d 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -14,7 +14,7 @@ export default function Home() { />
  1. - Get started by editing{" "} + Get started by editing{" "}-From Feature Branch app/page.tsx