Remove LocalMods from git, rsync directly to homelabvm
This commit is contained in:
@@ -1,19 +1,15 @@
|
|||||||
name: Deploy via rsync
|
name: Restart server
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- release
|
- release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
restart:
|
||||||
runs-on: [ ubuntu-22.04 ]
|
runs-on: [ ubuntu-22.04 ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- 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
|
- name: Setup SSH
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -21,20 +17,6 @@ jobs:
|
|||||||
chmod 600 ~/.ssh/deploy_key
|
chmod 600 ~/.ssh/deploy_key
|
||||||
ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts 2>/dev/null
|
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
|
- name: Restart server
|
||||||
run: |
|
run: |
|
||||||
ssh -i ~/.ssh/deploy_key \
|
ssh -i ~/.ssh/deploy_key \
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
LocalMods/
|
LocalMods/
|
||||||
|
LocalMods.tar.gz
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:5d5e9100b3bfd7b828058adcc8872978d573b99fb5b685e590b61f0aa3efa61d
|
|
||||||
size 965533546
|
|
||||||
24
prep
24
prep
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/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 os
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -9,7 +9,8 @@ BASE = os.path.dirname(os.path.abspath(__file__))
|
|||||||
PREPARE_LOCAL = os.path.join(BASE, "prepare_local")
|
PREPARE_LOCAL = os.path.join(BASE, "prepare_local")
|
||||||
AUTOGEN = os.path.join(BASE, "scripts", "autogen_config.py")
|
AUTOGEN = os.path.join(BASE, "scripts", "autogen_config.py")
|
||||||
LOCALMODS_DIR = os.path.join(BASE, "LocalMods")
|
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):
|
def log_ok(msg):
|
||||||
@@ -26,9 +27,9 @@ def main():
|
|||||||
msg = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else "Update LocalMods"
|
msg = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else "Update LocalMods"
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print("╔════════════════════════════════════╗")
|
print("╔═══════════════════════════════════════╗")
|
||||||
print("║ Prep: mods → tar → commit ║")
|
print("║ Prep: mods → rsync → config → commit║")
|
||||||
print("╚════════════════════════════════════╝")
|
print("╚═══════════════════════════════════════╝")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
log_info("Step 1/4: Copy mods from workshop...")
|
log_info("Step 1/4: Copy mods from workshop...")
|
||||||
@@ -36,12 +37,13 @@ def main():
|
|||||||
log_ok("LocalMods ready")
|
log_ok("LocalMods ready")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
log_info("Step 2/4: Taring LocalMods/...")
|
log_info("Step 2/4: Rsyncing LocalMods/ to server...")
|
||||||
if os.path.exists(TAR_PATH):
|
subprocess.run([
|
||||||
os.remove(TAR_PATH)
|
"rsync", "-avz", "--delete",
|
||||||
subprocess.run(["tar", "-czf", TAR_PATH, "-C", BASE, "LocalMods"], check=True)
|
"-e", "ssh -p 22",
|
||||||
size = os.path.getsize(TAR_PATH)
|
LOCALMODS_DIR + "/", RSYNC_DEST
|
||||||
log_ok(f"Created {TAR_PATH} ({size / 1024:.1f} KB)")
|
], check=True)
|
||||||
|
log_ok("LocalMods synced to homelabvm")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
log_info("Step 3/4: Generating config_player.xml...")
|
log_info("Step 3/4: Generating config_player.xml...")
|
||||||
|
|||||||
40
unpack
40
unpack
@@ -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()
|
|
||||||
Reference in New Issue
Block a user