push_requirements_update.py•1.4 kB
#!/usr/bin/env python3
import subprocess
import sys
import os
def run_command(cmd, cwd=None):
"""Run a command and return the result"""
try:
result = subprocess.run(
cmd,
shell=True,
capture_output=True,
text=True,
cwd=cwd,
timeout=60
)
return result.returncode == 0, result.stdout, result.stderr
except subprocess.TimeoutExpired:
return False, "", "Command timed out"
def main():
workspace = "/workspace"
os.chdir(workspace)
print("🔄 Adding requirements.txt to git...")
success, stdout, stderr = run_command("git add requirements.txt")
if not success:
print(f"❌ Failed to add file: {stderr}")
return False
print("📝 Committing changes...")
success, stdout, stderr = run_command('git commit -m "feat: Add email-validator dependency to requirements.txt"')
if not success:
print(f"❌ Failed to commit: {stderr}")
return False
print("🚀 Pushing to GitHub...")
success, stdout, stderr = run_command("git push origin main")
if not success:
print(f"❌ Failed to push: {stderr}")
return False
print("✅ Successfully pushed requirements.txt update to GitHub!")
return True
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)