.gitea/workflows/deploy.yml aktualisiert
This commit is contained in:
parent
f4cd1e51c0
commit
e8312268d2
|
|
@ -1,50 +1,95 @@
|
||||||
# .gitea/workflows/deploy.yml
|
# .gitea/workflows/deploy.yml
|
||||||
name: Deploy mindnet to llm-node
|
name: Deploy mindnet to llm-node
|
||||||
on: { push: { branches: [ "main" ] } }
|
on:
|
||||||
# on: {}
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
|
||||||
concurrency: { group: deploy-mindnet, cancel-in-progress: false }
|
concurrency:
|
||||||
|
group: deploy-mindnet
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: linux_host
|
runs-on: linux_host
|
||||||
env:
|
env:
|
||||||
DEPLOY_DIRS: "app scripts schemas docker tests requirements.txt README.md"
|
DEPLOY_USER: "llmadmin"
|
||||||
|
DEPLOY_HOST: "${{ secrets.DEPLOY_HOST }}"
|
||||||
TARGET_BASE: "/home/llmadmin/mindnet"
|
TARGET_BASE: "/home/llmadmin/mindnet"
|
||||||
|
# Whitelist der zu synchronisierenden Einträge (keine Caches!)
|
||||||
|
DEPLOY_DIRS: "app scripts schemas docker tests requirements.txt README.md"
|
||||||
|
# Optional: HF Cache global außerhalb TARGET_BASE (empfohlen)
|
||||||
|
HF_HOME: "/home/llmadmin/.cache/huggingface"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: https://github.com/actions/checkout@v4
|
uses: https://github.com/actions/checkout@v4
|
||||||
- name: Ensure target base
|
|
||||||
run: install -d "$TARGET_BASE"
|
- name: Ensure target base exists
|
||||||
- name: Deploy whitelisted
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
ssh -o StrictHostKeyChecking=no "$DEPLOY_USER@$DEPLOY_HOST" "mkdir -p '$TARGET_BASE' '$HF_HOME' && chown -R $DEPLOY_USER:$DEPLOY_USER '$TARGET_BASE' '$HF_HOME' || true"
|
||||||
IFS=' ' read -r -a DIRS <<< "$DEPLOY_DIRS"
|
|
||||||
for d in "${DIRS[@]}"; do
|
- name: Stop API (graceful)
|
||||||
if [ -e "$d" ]; then
|
|
||||||
if [ -d "$d" ]; then
|
|
||||||
install -d "$TARGET_BASE/$d"
|
|
||||||
rsync -a --delete --exclude='.git' \
|
|
||||||
--exclude='.env' --exclude='.env.*' --exclude='**/.env*' \
|
|
||||||
"$d"/ "$TARGET_BASE/$d"/
|
|
||||||
else
|
|
||||||
rsync -a "$d" "$TARGET_BASE/$d"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
- name: Python venv (idempotent)
|
|
||||||
run: |
|
|
||||||
cd "$TARGET_BASE"
|
|
||||||
[ -d .venv ] || python3 -m venv .venv
|
|
||||||
source .venv/bin/activate
|
|
||||||
pip install --upgrade pip
|
|
||||||
[ -f requirements.txt ] && pip install -r requirements.txt || true
|
|
||||||
- name: Optional — restart mindnet-api
|
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
run: |
|
run: |
|
||||||
if systemctl --user list-unit-files | grep -q '^mindnet-api.service'; then
|
ssh -o StrictHostKeyChecking=no "$DEPLOY_USER@$DEPLOY_HOST" '
|
||||||
|
if systemctl --user list-unit-files | grep -q "^mindnet-api.service"; then
|
||||||
|
systemctl --user stop mindnet-api.service || true
|
||||||
|
fi
|
||||||
|
'
|
||||||
|
|
||||||
|
- name: Deploy whitelisted (rsync)
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
SRC="$GITHUB_WORKSPACE"
|
||||||
|
DEST="$DEPLOY_USER@$DEPLOY_HOST:$TARGET_BASE/"
|
||||||
|
|
||||||
|
# Liste der Quellen vorbereiten (mit führendem ./ für --relative)
|
||||||
|
mapfile -t items < <(echo "$DEPLOY_DIRS" | tr " " "\n" | sed "s|^|./|")
|
||||||
|
cd "$SRC"
|
||||||
|
|
||||||
|
rsync -avz --delete --relative \
|
||||||
|
--omit-dir-times --no-perms --no-owner --no-group \
|
||||||
|
--exclude ".git" \
|
||||||
|
--exclude ".github" \
|
||||||
|
--exclude ".gitea" \
|
||||||
|
--exclude ".venv" \
|
||||||
|
--exclude "__pycache__" \
|
||||||
|
--exclude ".mypy_cache" \
|
||||||
|
--exclude ".pytest_cache" \
|
||||||
|
--exclude "hf_cache" \
|
||||||
|
--exclude "hf_cache/**" \
|
||||||
|
"${items[@]}" "$DEST"
|
||||||
|
|
||||||
|
- name: Fix ownership
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
ssh -o StrictHostKeyChecking=no "$DEPLOY_USER@$DEPLOY_HOST" "sudo chown -R $DEPLOY_USER:$DEPLOY_USER '$TARGET_BASE' || true"
|
||||||
|
|
||||||
|
- name: Python venv & requirements
|
||||||
|
run: |
|
||||||
|
ssh -o StrictHostKeyChecking=no "$DEPLOY_USER@$DEPLOY_HOST" "
|
||||||
|
set -e
|
||||||
|
cd '$TARGET_BASE'
|
||||||
|
[ -d .venv ] || python3 -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
[ -f requirements.txt ] && pip install -r requirements.txt || true
|
||||||
|
"
|
||||||
|
|
||||||
|
- name: Start/Restart mindnet-api
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
ssh -o StrictHostKeyChecking=no "$DEPLOY_USER@$DEPLOY_HOST" '
|
||||||
|
if systemctl --user list-unit-files | grep -q "^mindnet-api.service"; then
|
||||||
|
# HF_HOME außerhalb des Deploy-Baums setzen (robust gegen rsync --delete)
|
||||||
|
if ! systemctl --user cat mindnet-api.service | grep -q "Environment=HF_HOME="; then
|
||||||
|
echo "⚠️ Hinweis: Bitte Environment=HF_HOME in der Service-Unit setzen, z.B.:
|
||||||
|
[Service]
|
||||||
|
Environment=HF_HOME=/home/llmadmin/.cache/huggingface"
|
||||||
|
fi
|
||||||
systemctl --user restart mindnet-api.service
|
systemctl --user restart mindnet-api.service
|
||||||
systemctl --user --no-pager status mindnet-api.service --full -l || true
|
systemctl --user --no-pager status mindnet-api.service --full -l || true
|
||||||
else
|
else
|
||||||
echo "mindnet-api.service nicht vorhanden – übersprungen."
|
echo "mindnet-api.service nicht vorhanden – übersprungen."
|
||||||
fi
|
fi
|
||||||
|
'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user