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