From 22837960225936e6ea3a8236efa8926d89fcde31 Mon Sep 17 00:00:00 2001 From: Sreeram Date: Mon, 27 Apr 2026 14:30:20 +0530 Subject: [PATCH 1/2] Clean up CI pipeline --- .gitlab-ci.yml | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 17f1003..d4d8156 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,8 +8,9 @@ before_script: - echo $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY -.docker-compose-base: +.deploy: image: alpine:latest + stage: deploy before_script: - mkdir $HOME/.ssh - chmod 700 $HOME/.ssh @@ -21,21 +22,14 @@ - apk add --update --no-cache openssh rsync .docker-compose-deploy: - extends: .docker-compose-base + extends: .deploy script: - echo "Deploying $CI_PROJECT_NAME to $CI_ENVIRONMENT_NAME" - | ssh $SSH_USER@$DEPLOYMENT_HOST /bin/bash -s << EOT - set -eu - mkdir -p $DEPLOYMENT_PATH cd $DEPLOYMENT_PATH - if [ ! -d .git ]; then - git init - git remote add origin git@${CI_SERVER_HOST}:${CI_PROJECT_PATH}.git - else - git remote set-url origin git@${CI_SERVER_HOST}:${CI_PROJECT_PATH}.git - fi - git fetch origin + git stash + git fetch git checkout ${CI_COMMIT_TAG:-${CI_COMMIT_REF_NAME}} EOT - | @@ -54,7 +48,7 @@ EOT .docker-compose-recreate: - extends: .docker-compose-base + extends: .deploy script: - echo "Recreating stack on $DEPLOYMENT_HOST" - | @@ -65,7 +59,7 @@ EOT check: - stage: build + stage: test image: node:23-alpine script: - cd app @@ -93,7 +87,6 @@ docker-build-image-tag: - if: '$CI_COMMIT_BRANCH == "main"' deploy-stack:staging: - stage: deploy extends: .docker-compose-deploy needs: ["docker-build-image-tag"] when: manual @@ -105,7 +98,6 @@ deploy-stack:staging: url: $URL recreate-stack:staging: - stage: deploy extends: .docker-compose-recreate needs: ["deploy-stack:staging"] when: manual @@ -117,7 +109,6 @@ recreate-stack:staging: url: $URL deploy-stack:production: - stage: deploy extends: .docker-compose-deploy needs: ["docker-build-image-tag"] when: manual @@ -128,7 +119,6 @@ deploy-stack:production: url: $URL recreate-stack:production: - stage: deploy extends: .docker-compose-recreate needs: ["deploy-stack:production"] when: manual -- GitLab From a12152a29c147032f7a474962832b3cf261998c2 Mon Sep 17 00:00:00 2001 From: Sreeram Date: Mon, 27 Apr 2026 14:34:27 +0530 Subject: [PATCH 2/2] Fix for stage order --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4d8156..a1fb0cb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,10 @@ +--- +stages: + - test + - build + - deploy + + .docker: stage: build image: docker:26 -- GitLab