#!/usr/bin/env python3 import subprocess, json, sys # Get the token from git remote remote = subprocess.run( ["git", "remote", "get-url", "origin"], capture_output=True, text=True, cwd="/opt/data/projects/tabatago" ).stdout.strip() # Extract token from https://TOKEN@gitea.1000co.fr/... token = remote.split("@")[0].replace("https://", "") # Make API call import urllib.request url = "https://gitea.1000co.fr/api/v1/repos/millianlmx/tabatago/pulls" data = json.dumps({ "title": "ci: add iPhone deploy workflow + CI/CD setup docs", "body": "## Summary\n\nAdds CI/CD pipeline for automatic iPhone deployment on PR.\n\n### Changes\n- **.gitea/workflows/pr-iphone-deploy.yml**: Builds TabataGo for iPhone, installs on device, posts Ready to test comment, waits for LGTM/KO, auto-merges\n- **docs/ci-cd-setup.md**: Mac runner + secrets setup guide\n\n### Secrets required\n- `IPHONE_UDID` - target device UDID\n- `GITEA_TOKEN` - Gitea API token\n\nRuns on: `macos` runner", "head": "ci/iphone-deploy-workflow", "base": "main" }).encode() req = urllib.request.Request(url, data=data, method="POST") req.add_header("Authorization", f"token {token}") req.add_header("Content-Type", "application/json") try: with urllib.request.urlopen(req) as resp: result = json.loads(resp.read()) print(f"✅ PR created: #{result.get('number')} - {result.get('html_url', result.get('url', ''))}") print(json.dumps(result, indent=2)) except urllib.error.HTTPError as e: err = e.read().decode() print(f"❌ HTTP {e.code}: {err}") sys.exit(1)