Files
xkater/.woodpecker.yaml
Konstantin d7dd806be1
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Изменение .woodpecker.yaml 13
2026-04-12 20:57:33 +07:00

77 lines
2.2 KiB
YAML

# .woodpecker.yaml
steps:
# Шаг 1: Сборка ассетов темы
- name: build-assets
image: node:20-alpine
commands:
- cd wp-content/themes/xkater
- if [ -f package.json ]; then npm ci && npm run build; fi
when:
branch: main
# Шаг 2: Деплой на боевой сервер
- name: deploy-production
image: alpine:latest
environment:
SSH_KEY:
from_secret: PROD_SSH_KEY
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
# Шаг 3: Очистка кэша на сервере
- name: flush-cache
image: alpine:latest
environment:
SSH_KEY:
from_secret: PROD_SSH_KEY
SSH_USER:
from_secret: PROD_SSH_USER
SSH_HOST:
from_secret: PROD_SSH_HOST
REMOTE_PATH:
from_secret: REMOTE_PATH
commands:
- apk add --no-cache openssh-client
- 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
- |
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"
when:
branch: main