File size: 1,846 Bytes
667bab7 | 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #!/usr/bin/env python3
"""
Deploy Lao Python Learning Platform to Render.com (via CLI)
Prerequisites:
- pip install render-cli
- render login
"""
import os
import sys
import subprocess
from pathlib import Path
def check_render_cli():
"""Check if Render CLI is installed."""
try:
result = subprocess.run(["render", "--version"], capture_output=True, text=True)
if result.returncode == 0:
return result.stdout.strip()
except FileNotFoundError:
pass
return None
def deploy_to_render():
"""Deploy to Render using their CLI."""
# Check CLI
version = check_render_cli()
if not version:
print("โ Render CLI not found")
print(" Install: pip install render-cli")
print(" Then login: render login")
return False
print(f"โ Render CLI: {version}")
# Check credentials
token = os.environ.get("RENDER_API_KEY")
if not token:
print("โ ๏ธ RENDER_API_KEY not set")
print(" Get token from: https://dashboard.render.com/u/settings")
print(" Or use 'render login' instead")
return False
print(f"โ Token found: {token[:20]}...")
# Deploy
print("\n๐ Deploying to Render...")
deploy_script = Path(__file__).parent / "deploy_render.sh"
if deploy_script.exists():
result = subprocess.run(
["bash", str(deploy_script)],
cwd=Path(__file__).parent,
capture_output=True,
text=True
)
print(result.stdout)
if result.stderr:
print("STDERR:", result.stderr)
return result.returncode == 0
print("โ deploy_render.sh not found")
return False
if __name__ == "__main__":
success = deploy_to_render()
sys.exit(0 if success else 1)
|