This commit is contained in:
104
.woodpecker.yaml
104
.woodpecker.yaml
@@ -1,75 +1,49 @@
|
|||||||
when:
|
# .woodpecker.yaml
|
||||||
branch: main
|
|
||||||
event: push
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: debug-secrets
|
# Шаг 1: Сборка ассетов темы
|
||||||
image: alpine
|
|
||||||
environment:
|
|
||||||
MY_HOST:
|
|
||||||
from_secret: PROD_SSH_HOST
|
|
||||||
MY_USER:
|
|
||||||
from_secret: PROD_SSH_USER
|
|
||||||
commands:
|
|
||||||
- echo "HOST = $MY_HOST"
|
|
||||||
- echo "USER = $MY_USER"
|
|
||||||
|
|
||||||
- name: build-assets
|
- name: build-assets
|
||||||
image: node:20-alpine
|
image: node:20-alpine
|
||||||
commands:
|
commands:
|
||||||
- cd wp-content/themes/xkater
|
- cd wp-content/themes/xkater
|
||||||
- if [ -f package.json ]; then npm ci && npm run build; fi
|
- if [ -f package.json ]; then npm ci && npm run build; fi
|
||||||
|
when:
|
||||||
|
branch: main
|
||||||
|
|
||||||
|
# Шаг 2: Деплой на боевой сервер
|
||||||
- name: deploy-production
|
- name: deploy-production
|
||||||
image: alpine
|
image: drillster/drone-rsync
|
||||||
environment:
|
settings:
|
||||||
SSH_KEY:
|
user: ${PROD_SSH_USER}
|
||||||
from_secret: PROD_SSH_KEY
|
hosts:
|
||||||
SSH_HOST:
|
- ${PROD_SSH_HOST}
|
||||||
from_secret: PROD_SSH_HOST
|
port: 22
|
||||||
SSH_USER:
|
key: ${PROD_SSH_KEY}
|
||||||
from_secret: PROD_SSH_USER
|
source: ./wp-content/
|
||||||
REMOTE_PATH:
|
target: ${REMOTE_PATH}/wp-content/
|
||||||
from_secret: REMOTE_PATH
|
recursive: true
|
||||||
commands:
|
delete: false
|
||||||
- apk add --no-cache rsync openssh-client
|
args: >
|
||||||
- mkdir -p ~/.ssh
|
--exclude=uploads/
|
||||||
- echo "$SSH_KEY" > ~/.ssh/id_rsa
|
--exclude=plugins/akismet/
|
||||||
- chmod 600 ~/.ssh/id_rsa
|
--exclude=plugins/index.php
|
||||||
- ssh-keyscan -H $SSH_HOST >> ~/.ssh/known_hosts
|
--exclude=.git/
|
||||||
- |
|
--exclude=node_modules/
|
||||||
rsync -avz \
|
--exclude=.DS_Store
|
||||||
--exclude='uploads/' \
|
--exclude=mu-plugins/local-dev-performance.php
|
||||||
--exclude='plugins/akismet/' \
|
when:
|
||||||
--exclude='plugins/index.php' \
|
branch: main
|
||||||
--exclude='.git/' \
|
|
||||||
--exclude='node_modules/' \
|
|
||||||
--exclude='.DS_Store' \
|
|
||||||
--exclude='mu-plugins/local-dev-performance.php' \
|
|
||||||
-e "ssh -i ~/.ssh/id_rsa -p 22 -o StrictHostKeyChecking=no" \
|
|
||||||
./wp-content/ \
|
|
||||||
$SSH_USER@$SSH_HOST:$REMOTE_PATH/wp-content/
|
|
||||||
|
|
||||||
|
# Шаг 3: Очистка кэша на сервере
|
||||||
- name: flush-cache
|
- name: flush-cache
|
||||||
image: alpine
|
image: appleboy/drone-ssh
|
||||||
environment:
|
settings:
|
||||||
SSH_KEY:
|
host: ${PROD_SSH_HOST}
|
||||||
from_secret: PROD_SSH_KEY
|
username: ${PROD_SSH_USER}
|
||||||
SSH_HOST:
|
key: ${PROD_SSH_KEY}
|
||||||
from_secret: PROD_SSH_HOST
|
script:
|
||||||
SSH_USER:
|
- cd ${REMOTE_PATH}
|
||||||
from_secret: PROD_SSH_USER
|
- if command -v wp &> /dev/null; then wp cache flush; fi
|
||||||
REMOTE_PATH:
|
- touch wp-config.php
|
||||||
from_secret: REMOTE_PATH
|
when:
|
||||||
commands:
|
branch: main
|
||||||
- apk add --no-cache openssh-client
|
# Убрали status - он не нужен для этого шага
|
||||||
- mkdir -p ~/.ssh
|
|
||||||
- echo "$SSH_KEY" > ~/.ssh/id_rsa
|
|
||||||
- chmod 600 ~/.ssh/id_rsa
|
|
||||||
- ssh-keyscan -H $SSH_HOST >> ~/.ssh/known_hosts
|
|
||||||
- |
|
|
||||||
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST "
|
|
||||||
cd $REMOTE_PATH
|
|
||||||
if command -v wp > /dev/null 2>&1; then wp cache flush; fi
|
|
||||||
touch wp-config.php
|
|
||||||
"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user