This commit is contained in:
@@ -11,27 +11,39 @@ steps:
|
||||
|
||||
# Шаг 2: Деплой на боевой сервер
|
||||
- name: deploy-production
|
||||
image: drillster/drone-rsync
|
||||
settings:
|
||||
user:
|
||||
from_secret: PROD_SSH_USER
|
||||
hosts:
|
||||
from_secret: PROD_SSH_HOST
|
||||
port: 22
|
||||
key:
|
||||
image: alpine:latest
|
||||
environment:
|
||||
SSH_KEY:
|
||||
from_secret: PROD_SSH_KEY
|
||||
source: ./wp-content/
|
||||
target: /var/www/your-site/wp-content/
|
||||
recursive: true
|
||||
delete: false
|
||||
args: >
|
||||
--exclude=uploads/
|
||||
--exclude=plugins/akismet/
|
||||
--exclude=plugins/index.php
|
||||
--exclude=.git/
|
||||
--exclude=node_modules/
|
||||
--exclude=.DS_Store
|
||||
--exclude=mu-plugins/local-dev-performance.php
|
||||
SSH_USER:
|
||||
from_secret: PROD_SSH_USER
|
||||
SSH_HOST:
|
||||
from_secret: PROD_SSH_HOST
|
||||
REMOTE_PATH:
|
||||
from_secret: REMOTE_PATH
|
||||
commands:
|
||||
# Устанавливаем rsync и openssh
|
||||
- apk add --no-cache rsync openssh-client
|
||||
|
||||
# Настраиваем SSH-ключ
|
||||
- mkdir -p ~/.ssh
|
||||
- echo "$SSH_KEY" > ~/.ssh/id_rsa
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts 2>/dev/null
|
||||
|
||||
# Запускаем rsync
|
||||
- |
|
||||
rsync -az \
|
||||
--exclude=uploads/ \
|
||||
--exclude=plugins/akismet/ \
|
||||
--exclude=plugins/index.php \
|
||||
--exclude=.git/ \
|
||||
--exclude=node_modules/ \
|
||||
--exclude=.DS_Store \
|
||||
--exclude=mu-plugins/local-dev-performance.php \
|
||||
-e "ssh -p 22 -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no" \
|
||||
./wp-content/ \
|
||||
"$SSH_USER@$SSH_HOST:$REMOTE_PATH/wp-content/"
|
||||
when:
|
||||
branch: main
|
||||
|
||||
@@ -45,9 +57,14 @@ steps:
|
||||
from_secret: PROD_SSH_USER
|
||||
key:
|
||||
from_secret: PROD_SSH_KEY
|
||||
envs:
|
||||
- REMOTE_PATH
|
||||
script:
|
||||
- cd /var/www/your-site
|
||||
- if command -v wp &> /dev/null; then wp cache flush; fi
|
||||
- cd $REMOTE_PATH
|
||||
- if command -v wp > /dev/null 2>&1; then wp cache flush; fi
|
||||
- touch wp-config.php
|
||||
environment:
|
||||
REMOTE_PATH:
|
||||
from_secret: REMOTE_PATH
|
||||
when:
|
||||
branch: main
|
||||
|
||||
Reference in New Issue
Block a user