Latest local changes
This commit is contained in:
parent
6d0b83cf2b
commit
92acf81362
1 changed files with 43 additions and 101 deletions
108
deploy.py
108
deploy.py
|
|
@ -1,107 +1,49 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""
|
"""Check git status and redeploy."""
|
||||||
KV-Tube Deployment Script
|
|
||||||
Handles cleanup, git operations, and provides docker commands.
|
|
||||||
Run this with: exec(open("deploy.py").read())
|
|
||||||
"""
|
|
||||||
import os
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import os
|
||||||
|
|
||||||
# Files to remove
|
def run_cmd(cmd):
|
||||||
files_to_remove = [
|
|
||||||
"server.log",
|
|
||||||
"response.json",
|
|
||||||
"response_error.json",
|
|
||||||
"proxy_check.m3u8",
|
|
||||||
"nul",
|
|
||||||
"CONSOLE_ERROR_FIXES.md",
|
|
||||||
"DOWNLOAD_FIXES.md",
|
|
||||||
"TEST_REPORT.md",
|
|
||||||
"debug_transcript.py",
|
|
||||||
"generate_icons.py",
|
|
||||||
"deploy-docker.bat",
|
|
||||||
"deploy-docker.ps1",
|
|
||||||
"deploy_v2.ps1",
|
|
||||||
"cleanup.py",
|
|
||||||
]
|
|
||||||
|
|
||||||
def run_cmd(cmd, cwd=None):
|
|
||||||
"""Run a shell command and return success status."""
|
|
||||||
print(f"\n>>> {cmd}")
|
print(f"\n>>> {cmd}")
|
||||||
try:
|
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
|
||||||
result = subprocess.run(cmd, shell=True, cwd=cwd, capture_output=True, text=True)
|
|
||||||
if result.stdout:
|
if result.stdout:
|
||||||
print(result.stdout)
|
print(result.stdout)
|
||||||
if result.stderr:
|
if result.stderr:
|
||||||
print(result.stderr)
|
print(result.stderr)
|
||||||
return result.returncode == 0
|
return result.returncode == 0
|
||||||
except Exception as e:
|
|
||||||
print(f"Error: {e}")
|
|
||||||
return False
|
|
||||||
|
|
||||||
def main():
|
|
||||||
base_dir = os.getcwd()
|
|
||||||
print(f"Working directory: {base_dir}")
|
|
||||||
|
|
||||||
# Step 1: Cleanup
|
|
||||||
print("\n" + "="*50)
|
|
||||||
print("STEP 1: Cleaning up files...")
|
|
||||||
print("="*50)
|
print("="*50)
|
||||||
for filename in files_to_remove:
|
print("Checking git status...")
|
||||||
filepath = os.path.join(base_dir, filename)
|
|
||||||
if os.path.exists(filepath):
|
|
||||||
try:
|
|
||||||
os.remove(filepath)
|
|
||||||
print(f"✓ Removed: {filename}")
|
|
||||||
except Exception as e:
|
|
||||||
print(f"✗ Error removing {filename}: {e}")
|
|
||||||
else:
|
|
||||||
print(f"- Skipped (not found): {filename}")
|
|
||||||
|
|
||||||
# Step 2: Git operations
|
|
||||||
print("\n" + "="*50)
|
|
||||||
print("STEP 2: Git operations...")
|
|
||||||
print("="*50)
|
print("="*50)
|
||||||
|
run_cmd("git status")
|
||||||
|
|
||||||
# Add remote if not exists
|
print("\n" + "="*50)
|
||||||
run_cmd("git remote add private https://git.khoavo.myds.me/vndangkhoa/kv-tube 2>/dev/null || true")
|
print("Staging all changes...")
|
||||||
|
print("="*50)
|
||||||
# Stage all changes
|
|
||||||
run_cmd("git add .")
|
run_cmd("git add .")
|
||||||
|
|
||||||
# Commit
|
|
||||||
run_cmd('git commit -m "Cleanup and documentation update"')
|
|
||||||
|
|
||||||
# Push to origin
|
|
||||||
print("\nPushing to origin...")
|
|
||||||
run_cmd("git push origin main || git push origin master")
|
|
||||||
|
|
||||||
# Push to private
|
|
||||||
print("\nPushing to private server...")
|
|
||||||
run_cmd("git push private main || git push private master")
|
|
||||||
|
|
||||||
# Step 3: Docker instructions
|
|
||||||
print("\n" + "="*50)
|
print("\n" + "="*50)
|
||||||
print("STEP 3: Docker Build & Push")
|
print("Committing...")
|
||||||
print("="*50)
|
print("="*50)
|
||||||
print("\nTo build and push Docker image, run these commands manually:")
|
run_cmd('git commit -m "Latest local changes"')
|
||||||
print(" docker build -t vndangkhoa/kv-tube:latest .")
|
|
||||||
print(" docker push vndangkhoa/kv-tube:latest")
|
|
||||||
|
|
||||||
# Optionally try to run docker commands
|
print("\n" + "="*50)
|
||||||
print("\nAttempting Docker build...")
|
print("Pushing to GitHub...")
|
||||||
|
print("="*50)
|
||||||
|
run_cmd("git push origin main")
|
||||||
|
|
||||||
|
print("\n" + "="*50)
|
||||||
|
print("Pushing to Forgejo...")
|
||||||
|
print("="*50)
|
||||||
|
run_cmd("git push private main")
|
||||||
|
|
||||||
|
print("\n" + "="*50)
|
||||||
|
print("Building Docker image...")
|
||||||
|
print("="*50)
|
||||||
if run_cmd("docker build -t vndangkhoa/kv-tube:latest ."):
|
if run_cmd("docker build -t vndangkhoa/kv-tube:latest ."):
|
||||||
print("\nAttempting Docker push...")
|
print("\nPushing Docker image...")
|
||||||
run_cmd("docker push vndangkhoa/kv-tube:latest")
|
run_cmd("docker push vndangkhoa/kv-tube:latest")
|
||||||
|
|
||||||
print("\n" + "="*50)
|
print("\n" + "="*50)
|
||||||
print("DEPLOYMENT COMPLETE!")
|
print("DEPLOYMENT COMPLETE!")
|
||||||
print("="*50)
|
print("="*50)
|
||||||
print("\nYou can delete this file (deploy.py) now.")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
else:
|
|
||||||
# When run via exec()
|
|
||||||
main()
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue