64 lines
1.8 KiB
YAML
64 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_TARGET_BRANCH:-main}"
|
|
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
|
|
# The pipe '|' ensures the whole block is sent as a script to the server
|
|
script: |
|
|
# 1. Create directory structure in home folder (no permission issues here)
|
|
mkdir -p ~/na-granicelife/assets/mp4
|
|
|
|
# 2. Clone code to temp folder on the server
|
|
rm -rf /tmp/na-granice-deploy
|
|
git clone --depth 1 --branch main https://gitea.allowlgroup.ru/na-granicelife.ru/front.git /tmp/na-granice-deploy
|
|
|
|
# 3. Copy all files EXCEPT the mp4 folder
|
|
# find locates files, -not excludes the mp4 path, cp copies them
|
|
find /tmp/na-granice-deploy -type f -not -path '*assets/mp4*' -exec cp --no-preserve=mode {} ~/na-granicelife \;
|
|
|
|
# 4. Clean up temp folder
|
|
rm -rf /tmp/na-granice-deploy
|
|
|
|
# 5. Run docker compose commands directly on the server
|
|
cd ~/na-granicelife
|
|
docker compose pull web
|
|
docker compose up -d
|
|
docker image prune -f
|
|
docker compose ps
|
|
|
|
trigger:
|
|
branch:
|
|
- main
|
|
event:
|
|
- push
|
|
- custom
|