git_push.py•1.63 kB
#!/usr/bin/env python3
import subprocess
import os
import signal
import time
def run_git_command(cmd):
"""Execute git command with timeout handling"""
try:
print(f"Running: {' '.join(cmd)}")
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
print(f"Return code: {result.returncode}")
print(f"Output: {result.stdout}")
if result.stderr:
print(f"Error: {result.stderr}")
return result.returncode == 0
except subprocess.TimeoutExpired:
print(f"Command timeout: {' '.join(cmd)}")
return False
except Exception as e:
print(f"Error running command: {e}")
return False
def main():
# Change to workspace directory
os.chdir('/workspace')
# Kill any Railway server processes
print("Killing Railway server processes...")
try:
subprocess.run(['pkill', '-f', 'start_railway.py'], timeout=10)
time.sleep(2)
except:
pass
# Git operations
print("Starting git operations...")
# Add files
if not run_git_command(['git', 'add', '.']):
print("Git add failed")
return
# Commit
commit_msg = "Add manual JWT token generation endpoint and fix auth middleware for public routes"
if not run_git_command(['git', 'commit', '-m', commit_msg]):
print("Git commit failed")
return
# Push
if not run_git_command(['git', 'push', 'origin', 'main']):
print("Git push failed")
return
print("Git operations completed successfully!")
if __name__ == "__main__":
main()