Files
exposedgays/deploy/deploy-v2-features.py

64 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""Push v2 features and deploy ExposedGays on Coolify."""
import paramiko
import subprocess
import os
HOST = "10.10.0.10"
USER = "localadministrator"
PASS = "Bbt9115xty9176!"
GITEA_TOKEN = "5c323b8ea677d78b201341f6833d57156a607008"
APP = "ira4bw4nhbvm87o7s3fgqu6v"
REPO_DIR = r"C:\Users\Local Administrator\exposedgays"
def local_git(*args):
cmd = ["git", "-C", REPO_DIR] + list(args)
print("$", " ".join(cmd))
r = subprocess.run(cmd, capture_output=True, text=True)
print(r.stdout[-4000:] if r.stdout else "")
if r.stderr:
print(r.stderr[-2000:])
return r.returncode
# Stage and commit locally
local_git("add", "-A")
local_git("status", "--short")
local_git(
"commit", "-m",
"v2: ID verification by state, 15 photos/5 albums, 20 quick replies, logo, mobile polish"
)
local_git("push", "origin", "main")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, username=USER, password=PASS, timeout=20, allow_agent=False, look_for_keys=False)
def run(cmd, t=300):
print("$", cmd[:180])
_, o, e = c.exec_command(cmd, timeout=t)
code = o.channel.recv_exit_status()
out = (o.read() + e.read()).decode(errors="replace")
print(out[-6000:])
print("exit", code, "\n")
return code, out
run("cd /tmp/exposedgays && git pull origin main")
run(
"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
f"curl -sS -X POST 'http://127.0.0.1:8000/api/v1/deploy?uuid={APP}&force_rebuild=true' "
'-H "Authorization: Bearer $TOKEN"'
)
for i in range(120):
_, out = run("docker exec coolify php artisan queue:work --queue=high,default --once --timeout=900 2>&1", t=920)
if "ApplicationDeploymentJob" in out:
if "DONE" in out:
print("=== DEPLOY SUCCESS ===")
break
if "FAIL" in out:
print("=== DEPLOY FAILED ===")
break
run("curl -sS -o /dev/null -w '%{http_code}' https://exposedgays.com/ 2>&1 || curl -sS -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/ 2>&1")
c.close()
print("Done.")