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