-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeploy.py
More file actions
51 lines (40 loc) · 1.82 KB
/
deploy.py
File metadata and controls
51 lines (40 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import subprocess
import os
def run_command(command):
"""Helper to run shell commands and return output."""
result = subprocess.run(command, capture_output=True, text=True)
return result
def deploy_to_github(repo_url):
try:
if not os.path.exists('index.html'):
print("❌ Error: index.html not found.")
return
# 1. Initialize Git if needed
if not os.path.exists('.git'):
print("📦 Initializing Git...")
subprocess.run(["git", "init"], check=True)
subprocess.run(["git", "branch", "-M", "main"], check=True)
# 2. Configure Remote
subprocess.run(["git", "remote", "remove", "origin"], stderr=subprocess.DEVNULL)
subprocess.run(["git", "remote", "add", "origin", repo_url], check=True)
# 3. Stage changes
subprocess.run(["git", "add", "."], check=True)
# 4. CHECK FOR CHANGES BEFORE COMMITTING
# This prevents the "exit status 1" error
status = run_command(["git", "status", "--porcelain"])
if not status.stdout.strip():
print("✨ Everything is already up to date. No changes to deploy.")
return
# 5. Commit and Push
print("💾 Changes detected. Committing...")
subprocess.run(["git", "commit", "-m", "v10.0 Multiplayer Update"], check=True)
print(f"📤 Uploading to {repo_url}...")
subprocess.run(["git", "push", "-u", "origin", "main", "--force"], check=True)
print("\n✅ DEPLOYMENT SUCCESSFUL!")
except subprocess.CalledProcessError as e:
print(f"❌ Git Command Failed: {e}")
except Exception as e:
print(f"❌ Unexpected Error: {e}")
if __name__ == "__main__":
REPO = "https://github.com/infrareactive/sci-fi-cyber-chess.git"
deploy_to_github(REPO)