68 lines
1.8 KiB
YAML
68 lines
1.8 KiB
YAML
kind: pipeline
|
|
type: docker
|
|
name: ci-cd-full
|
|
|
|
steps:
|
|
# Step 1: Build and push image to Gitea Registry
|
|
- name: docker-build
|
|
image: plugins/docker
|
|
pull: always
|
|
settings:
|
|
registry: gitea.allowlgroup.ru
|
|
repo: gitea.allowlgroup.ru/na-granicelife.ru/front
|
|
tags:
|
|
- latest
|
|
- ${DRONE_COMMIT_SHA}
|
|
username:
|
|
from_secret: registry_username
|
|
password:
|
|
from_secret: registry_password
|
|
|
|
# Step 2: Deploy via SSH
|
|
- name: ssh-deploy
|
|
image: appleboy/drone-ssh:1.7
|
|
pull: always
|
|
settings:
|
|
host:
|
|
from_secret: deploy_host
|
|
port:
|
|
from_secret: deploy_port
|
|
user:
|
|
from_secret: deploy_user
|
|
password:
|
|
from_secret: deploy_password
|
|
script_stop: true
|
|
script: |
|
|
set -e
|
|
|
|
APP_DIR="$HOME/na-granicelife"
|
|
TMP_DIR="/tmp/na-granice-deploy"
|
|
|
|
# 1. Сохраняем mp4 перед обновлением файлов
|
|
mkdir -p "$APP_DIR/assets/mp4"
|
|
|
|
# 2. Клонируем свежую версию репозитория
|
|
rm -rf "$TMP_DIR"
|
|
git clone --depth 1 --branch main https://gitea.allowlgroup.ru/na-granicelife.ru/front.git "$TMP_DIR"
|
|
|
|
# 3. Копируем всё, кроме mp4 и .git (tar preserves directory structure)
|
|
tar -C "$TMP_DIR" -cf - --exclude=./.git --exclude=./assets/mp4 . \
|
|
| tar -C "$APP_DIR" -xf -
|
|
|
|
# 4. Чистим временную директорию
|
|
rm -rf "$TMP_DIR"
|
|
|
|
# 5. Пересобираем и перезапускаем контейнер
|
|
cd "$APP_DIR"
|
|
docker compose pull web
|
|
docker compose up -d --remove-orphans
|
|
docker image prune -f
|
|
docker compose ps
|
|
|
|
trigger:
|
|
branch:
|
|
- main
|
|
event:
|
|
- push
|
|
- custom
|