ci: ci: ci:

This commit is contained in:
ITQ
2025-03-01 01:53:52 +03:00
parent d1a40d6c7d
commit 6e5ecc0f3a
+12 -10
View File
@@ -52,22 +52,24 @@ deploy:
image: alpine:latest image: alpine:latest
stage: deploy stage: deploy
rules: rules:
- if: $CI_COMMIT_REF_NAME == "master" - if: '$CI_COMMIT_REF_NAME == "master"'
variables: variables:
SSH_HOST: "prod-team-15-2pc0i3lc.final.prodcontest.ru" SSH_HOST: "prod-team-15-2pc0i3lc.final.prodcontest.ru"
SSH_USER: "ubuntu" SSH_USER: "ubuntu"
SSH_ADDRESS: $SSH_USER@$SSH_HOST SSH_ADDRESS: "$SSH_USER@$SSH_HOST"
SSH_PRIVATE_KEY_BASE64: "$ENV_PRIVATE_KEY_BASE64" SSH_PRIVATE_KEY_BASE64: "$ENV_PRIVATE_KEY_BASE64"
before_script: before_script:
- apk add --no-cache openssh-client - apk add --no-cache openssh-client
script: script:
- mkdir -p ~/.ssh - mkdir -p ~/.ssh && chmod 700 ~/.ssh
- echo "$SSH_PRIVATE_KEY_BASE64" | base64 -d > ~/.ssh/id_rsa - printf "%s" "$SSH_PRIVATE_KEY_BASE64" | base64 -d -i > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa
- scp -o StrictHostKeyChecking=no -r infrastructure/ compose.yaml ${SSH_USER}@${SSH_HOST}:~/deploy/ - ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts
- ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} " - scp -C -r infrastructure/ compose.yaml "$SSH_ADDRESS":~/deploy/
cd ~/deploy && - ssh "$SSH_ADDRESS" << 'EOF'
docker compose pull && set -e
docker compose down && cd ~/deploy
docker compose pull
docker compose down
docker compose up -d --remove-orphans docker compose up -d --remove-orphans
" EOF