Remove LocalMods from git, rsync directly to homelabvm

This commit is contained in:
2026-06-09 13:35:00 +03:00
parent 396753c367
commit 10859a335b
5 changed files with 16 additions and 74 deletions

View File

@@ -1,19 +1,15 @@
name: Deploy via rsync
name: Restart server
on:
push:
branches:
- release
jobs:
deploy:
restart:
runs-on: [ ubuntu-22.04 ]
steps:
- uses: actions/checkout@v4
- name: Install rsync
run: sudo apt-get update -qq && sudo apt-get install -y -qq rsync
continue-on-error: true
- name: Setup SSH
run: |
mkdir -p ~/.ssh
@@ -21,20 +17,6 @@ jobs:
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts 2>/dev/null
- name: Rsync to /opt/barotrauma
run: |
rsync -avz --delete \
--exclude=.git --exclude=.gitea \
-e "ssh -i ~/.ssh/deploy_key" \
./ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:/opt/barotrauma/
- name: Extract LocalMods on server
run: |
ssh -i ~/.ssh/deploy_key \
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} \
"cd /opt/barotrauma && \
[ -f LocalMods.tar.gz ] && tar -xzf LocalMods.tar.gz && rm -f LocalMods.tar.gz && echo 'LocalMods extracted' || echo 'No LocalMods.tar.gz'"
- name: Restart server
run: |
ssh -i ~/.ssh/deploy_key \

1
.gitignore vendored
View File

@@ -1 +1,2 @@
LocalMods/
LocalMods.tar.gz

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:5d5e9100b3bfd7b828058adcc8872978d573b99fb5b685e590b61f0aa3efa61d
size 965533546

24
prep
View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Prepare local mods, tar them, generate config, and commit."""
"""Prepare local mods, rsync to server, generate config, and commit."""
import os
import subprocess
@@ -9,7 +9,8 @@ BASE = os.path.dirname(os.path.abspath(__file__))
PREPARE_LOCAL = os.path.join(BASE, "prepare_local")
AUTOGEN = os.path.join(BASE, "scripts", "autogen_config.py")
LOCALMODS_DIR = os.path.join(BASE, "LocalMods")
TAR_PATH = os.path.join(BASE, "LocalMods.tar.gz")
RSYNC_DEST = "root@homelabvm:/opt/barotrauma/LocalMods/"
def log_ok(msg):
@@ -26,9 +27,9 @@ def main():
msg = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else "Update LocalMods"
print()
print("╔════════════════════════════════════╗")
print("║ Prep: mods → tar → commit ║")
print("╚════════════════════════════════════╝")
print("╔═══════════════════════════════════════╗")
print("║ Prep: mods → rsync → config → commit║")
print("╚═══════════════════════════════════════╝")
print()
log_info("Step 1/4: Copy mods from workshop...")
@@ -36,12 +37,13 @@ def main():
log_ok("LocalMods ready")
print()
log_info("Step 2/4: Taring LocalMods/...")
if os.path.exists(TAR_PATH):
os.remove(TAR_PATH)
subprocess.run(["tar", "-czf", TAR_PATH, "-C", BASE, "LocalMods"], check=True)
size = os.path.getsize(TAR_PATH)
log_ok(f"Created {TAR_PATH} ({size / 1024:.1f} KB)")
log_info("Step 2/4: Rsyncing LocalMods/ to server...")
subprocess.run([
"rsync", "-avz", "--delete",
"-e", "ssh -p 22",
LOCALMODS_DIR + "/", RSYNC_DEST
], check=True)
log_ok("LocalMods synced to homelabvm")
print()
log_info("Step 3/4: Generating config_player.xml...")

40
unpack
View File

@@ -1,40 +0,0 @@
#!/usr/bin/env python3
"""Unpack LocalMods.tar.gz into LocalMods/ and remove the archive."""
import os
import subprocess
import sys
BASE = os.path.dirname(os.path.abspath(__file__))
TAR_PATH = os.path.join(BASE, "LocalMods.tar.gz")
def log_ok(msg):
print(f"\033[92m✓\033[0m {msg}")
def log_info(msg):
print(f"• {msg}")
def log_err(msg):
print(f"\033[91m✗\033[0m {msg}", file=sys.stderr)
def main():
print()
if not os.path.isfile(TAR_PATH):
log_err(f"Not found: {TAR_PATH}")
sys.exit(1)
log_info(f"Extracting: {TAR_PATH}")
subprocess.run(["tar", "-xzf", TAR_PATH, "-C", BASE], check=True)
size = os.path.getsize(TAR_PATH)
os.remove(TAR_PATH)
log_ok(f"Extracted to {os.path.join(BASE, 'LocalMods')}/")
log_ok(f"Removed archive ({size / 1024:.1f} KB freed)")
print()
if __name__ == "__main__":
main()