Latest local changes
This commit is contained in:
parent
6d0b83cf2b
commit
92acf81362
1 changed files with 43 additions and 101 deletions
122
deploy.py
122
deploy.py
|
|
@ -1,107 +1,49 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
KV-Tube Deployment Script
|
||||
Handles cleanup, git operations, and provides docker commands.
|
||||
Run this with: exec(open("deploy.py").read())
|
||||
"""
|
||||
import os
|
||||
"""Check git status and redeploy."""
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Files to remove
|
||||
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."""
|
||||
def run_cmd(cmd):
|
||||
print(f"\n>>> {cmd}")
|
||||
try:
|
||||
result = subprocess.run(cmd, shell=True, cwd=cwd, capture_output=True, text=True)
|
||||
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
|
||||
if result.stdout:
|
||||
print(result.stdout)
|
||||
if result.stderr:
|
||||
print(result.stderr)
|
||||
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}")
|
||||
print("="*50)
|
||||
print("Checking git status...")
|
||||
print("="*50)
|
||||
run_cmd("git status")
|
||||
|
||||
# Step 1: Cleanup
|
||||
print("\n" + "="*50)
|
||||
print("STEP 1: Cleaning up files...")
|
||||
print("="*50)
|
||||
for filename in files_to_remove:
|
||||
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}")
|
||||
print("\n" + "="*50)
|
||||
print("Staging all changes...")
|
||||
print("="*50)
|
||||
run_cmd("git add .")
|
||||
|
||||
# Step 2: Git operations
|
||||
print("\n" + "="*50)
|
||||
print("STEP 2: Git operations...")
|
||||
print("="*50)
|
||||
print("\n" + "="*50)
|
||||
print("Committing...")
|
||||
print("="*50)
|
||||
run_cmd('git commit -m "Latest local changes"')
|
||||
|
||||
# Add remote if not exists
|
||||
run_cmd("git remote add private https://git.khoavo.myds.me/vndangkhoa/kv-tube 2>/dev/null || true")
|
||||
print("\n" + "="*50)
|
||||
print("Pushing to GitHub...")
|
||||
print("="*50)
|
||||
run_cmd("git push origin main")
|
||||
|
||||
# Stage all changes
|
||||
run_cmd("git add .")
|
||||
print("\n" + "="*50)
|
||||
print("Pushing to Forgejo...")
|
||||
print("="*50)
|
||||
run_cmd("git push private main")
|
||||
|
||||
# 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("STEP 3: Docker Build & Push")
|
||||
print("="*50)
|
||||
print("\nTo build and push Docker image, run these commands manually:")
|
||||
print(" docker build -t vndangkhoa/kv-tube:latest .")
|
||||
print(" docker push vndangkhoa/kv-tube:latest")
|
||||
|
||||
# Optionally try to run docker commands
|
||||
print("\nAttempting Docker build...")
|
||||
if run_cmd("docker build -t vndangkhoa/kv-tube:latest ."):
|
||||
print("\nAttempting Docker push...")
|
||||
print("\n" + "="*50)
|
||||
print("Building Docker image...")
|
||||
print("="*50)
|
||||
if run_cmd("docker build -t vndangkhoa/kv-tube:latest ."):
|
||||
print("\nPushing Docker image...")
|
||||
run_cmd("docker push vndangkhoa/kv-tube:latest")
|
||||
|
||||
print("\n" + "="*50)
|
||||
print("DEPLOYMENT COMPLETE!")
|
||||
print("="*50)
|
||||
print("\nYou can delete this file (deploy.py) now.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
else:
|
||||
# When run via exec()
|
||||
main()
|
||||
print("\n" + "="*50)
|
||||
print("DEPLOYMENT COMPLETE!")
|
||||
print("="*50)
|
||||
|
|
|
|||
Loading…
Reference in a new issue