31 lines
973 B
YAML
31 lines
973 B
YAML
stages:
|
|
- deploy
|
|
|
|
deploy_production:
|
|
stage: deploy
|
|
image: alpine:3.20
|
|
environment:
|
|
name: production
|
|
url: https://api-finance.ai-assistant-bot.xyz
|
|
rules:
|
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
when: manual
|
|
allow_failure: false
|
|
before_script:
|
|
- apk add --no-cache openssh-client rsync
|
|
- mkdir -p ~/.ssh
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
|
|
- chmod 600 ~/.ssh/id_rsa
|
|
- ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
|
script:
|
|
- ssh "$DEPLOY_USER@$DEPLOY_HOST" "mkdir -p /opt/apps/api-finance"
|
|
- rsync -az --delete \
|
|
--exclude='.git' \
|
|
--exclude='.env' \
|
|
--exclude='.env.*' \
|
|
--exclude='node_modules' \
|
|
--exclude='coverage' \
|
|
--exclude='dist' \
|
|
./ "$DEPLOY_USER@$DEPLOY_HOST:/opt/apps/api-finance/"
|
|
- ssh "$DEPLOY_USER@$DEPLOY_HOST" "cd /opt/apps/api-finance && docker compose -f docker-compose.server.yml up -d --build"
|