red_eye, Спасибо большое, получилось серез отдельную директорию на сервере!
конфиг принял вот такой вид[CODE]stages:
- deploy
variables:
host_remote: 82.146.34.161
port_remote: 22
GIT_STRATEGY: none
deploy_path: /home/deploy/site-name.ru/
stage_remote: /home/bitrix/ext_www/stage.site-name.ru/
prod_remote: /home/bitrix/www/
copy-files-to-stage:
stage: deploy
tags:
- deploy
before_script:
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
script:
- echo "Deploying application..."
- ssh -o StrictHostKeyChecking=no bitrix@$host_remote -p $port_remote -v "cd ${deploy_path}; git checkout stage; git fetch && git reset --hard origin/stage; pwd; rsync -atv --exclude .git --exclude .gitlab-ci.yml --exclude .gitignore ${deploy_path} ${stage_remote}"
- hostname
- pwd
- whoami
- echo "Application successfully deployed!"
only:
- stage
copy-files-to-prod:
stage: deploy
tags:
- deploy
before_script:
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
script:
- echo "Deploying application..."
- ssh -o StrictHostKeyChecking=no bitrix@$host_remote -p $port_remote -v "cd ${deploy_path}; git checkout main; git fetch && git reset --hard origin/main; pwd; rsync -atv --exclude .git --exclude .gitlab-ci.yml --exclude .gitignore ${deploy_path} ${prod_remote}"
- hostname
- pwd
- whoami
- echo "Application successfully deployed!"
only:
- main[/CODE]
deploy_path: /home/deploy/site-name.ru/ - это директория в которую склонировал репозитарий с GitLab