diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d9ff5654b191fc79b61aad2dc9d7e53ae46c9e66..96784b80ebd428d26e5a10863565b5a05964634b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,6 +69,13 @@ test:unit: - ssh $DOCKER_HOST "cd $PATH_STAGING" - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - docker pull $CI_REGISTRY_IMAGE/env + script: + - echo "Deploying to ($SSH_USER@$BACKEND_HOST)" + - ssh $SSH_USER@$BACKEND_HOST "cd $DEPLOYMENT_PATH && git stash && git pull && git checkout $BRANCH && rm .env .env.prod && rm docker-compose.yml && mv docker-compose.prod.yml docker-compose.yml" + - scp $ENV_FILE $SSH_USER@$BACKEND_HOST:$DEPLOYMENT_PATH/.env + - ssh $SSH_USER@$BACKEND_HOST "cd $DEPLOYMENT_PATH + && sed -i 's/SPOT_DOCKER_TAG=master/SPOT_DOCKER_TAG=$SPOT_DOCKER_TAG/g' .env + && docker-compose pull && docker-compose stop filtron && sleep 2 && docker-compose up -d && docker-compose restart spot-nginx" deploy:spot.murenatest.io.backend1: extends: .deploy:template @@ -83,13 +90,7 @@ deploy:spot.murenatest.io.backend1: variables: DOCKER_HOST: ssh://${SSH_USER}@${BACKEND_HOST} SPOT_DOCKER_TAG: ${CI_COMMIT_REF_SLUG} - script: - - echo "Deploying to ($SSH_USER@$BACKEND_HOST)" - - ssh $SSH_USER@$BACKEND_HOST "cd $DEPLOYMENT_PATH && git stash && git fetch && git checkout $CI_COMMIT_REF_NAME && rm .env .env.prod && rm docker-compose.yml && mv docker-compose.prod.yml docker-compose.yml" - - scp $ENV_FILE $SSH_USER@$BACKEND_HOST:$DEPLOYMENT_PATH/.env - - ssh $SSH_USER@$BACKEND_HOST "cd $DEPLOYMENT_PATH - && sed -i 's/SPOT_DOCKER_TAG=master/SPOT_DOCKER_TAG=$SPOT_DOCKER_TAG/g' .env - && docker-compose pull && docker-compose stop filtron && sleep 2 && docker-compose up -d" + BRANCH: ${CI_COMMIT_REF_NAME} deploy:spot.murenatest.io.backend2: extends: .deploy:template @@ -104,18 +105,13 @@ deploy:spot.murenatest.io.backend2: variables: DOCKER_HOST: ssh://${SSH_USER}@${BACKEND_HOST} SPOT_DOCKER_TAG: ${CI_COMMIT_REF_SLUG} - script: - - echo "Deploying to ($SSH_USER@$BACKEND_HOST)" - - ssh $SSH_USER@$BACKEND_HOST "cd $DEPLOYMENT_PATH && git stash && git fetch && git checkout $CI_COMMIT_REF_NAME && rm .env .env.prod && rm docker-compose.yml && mv docker-compose.prod.yml docker-compose.yml" - - scp $ENV_FILE $SSH_USER@$BACKEND_HOST:$DEPLOYMENT_PATH/.env - - ssh $SSH_USER@$BACKEND_HOST "cd $DEPLOYMENT_PATH - && sed -i 's/SPOT_DOCKER_TAG=master/SPOT_DOCKER_TAG=$SPOT_DOCKER_TAG/g' .env - && docker-compose pull && docker-compose stop filtron && sleep 2 && docker-compose up -d" + BRANCH: ${CI_COMMIT_REF_NAME} deploy:spot.murena.io.backend1: extends: .deploy:template only: - tags + when: manual environment: name: ecloud1 deployment_tier: production @@ -123,18 +119,13 @@ deploy:spot.murena.io.backend1: variables: DOCKER_HOST: ssh://${SSH_USER}@${BACKEND_HOST} SPOT_DOCKER_TAG: ${CI_COMMIT_REF_SLUG} - script: - - echo "Deploying to ($SSH_USER@$BACKEND_HOST)" - - ssh $SSH_USER@$BACKEND_HOST "cd $DEPLOYMENT_PATH && git stash && git fetch && git checkout master && rm .env .env.prod && rm docker-compose.yml && mv docker-compose.prod.yml docker-compose.yml" - - scp $ENV_FILE $SSH_USER@$BACKEND_HOST:$DEPLOYMENT_PATH/.env - - ssh $SSH_USER@$BACKEND_HOST "cd $DEPLOYMENT_PATH - && sed -i 's/SPOT_DOCKER_TAG=master/SPOT_DOCKER_TAG=$SPOT_DOCKER_TAG/g' .env - && docker-compose pull && docker-compose stop filtron && sleep 2 && docker-compose up -d" + BRANCH: master deploy:spot.murena.io.backend2: extends: .deploy:template only: - tags + when: manual environment: name: ecloud2 deployment_tier: production @@ -142,11 +133,4 @@ deploy:spot.murena.io.backend2: variables: DOCKER_HOST: ssh://${SSH_USER}@${BACKEND_HOST} SPOT_DOCKER_TAG: ${CI_COMMIT_REF_SLUG} - script: - - echo "Deploying to ($SSH_USER@$BACKEND_HOST)" - - ssh $SSH_USER@$BACKEND_HOST "cd $DEPLOYMENT_PATH && git stash && git fetch && git checkout master && rm .env .env.prod && rm docker-compose.yml && mv docker-compose.prod.yml docker-compose.yml" - - scp $ENV_FILE $SSH_USER@$BACKEND_HOST:$DEPLOYMENT_PATH/.env - - ssh $SSH_USER@$BACKEND_HOST "cd $DEPLOYMENT_PATH - && sed -i 's/SPOT_DOCKER_TAG=master/SPOT_DOCKER_TAG=$SPOT_DOCKER_TAG/g' .env - && docker-compose pull && docker-compose stop filtron && sleep 2 && docker-compose up -d" - + BRANCH: master