donkeycar-rl-autoresearch/create_gitea_repo.py

39 lines
1.1 KiB
Python

import os
import sys
import requests
import subprocess
# --- Config ---
GITEA_URL = "https://paje.ca"
USERNAME = "paulh"
REPO = "donkeycar-rl-autoresearch"
TOKEN = "6e97da632ceaaf4bef8e070bd2e844089b3e680a"
api_url = f"{GITEA_URL}/api/v1/user/repos"
git_url = f"{GITEA_URL}/{USERNAME}/{REPO}.git"
# --- Create repo on Gitea ---
headers = {"Authorization": f"token {TOKEN}"}
data = {
"name": REPO,
"description": "Research-grade DonkeyCar RL autoresearch and sweep system.",
"private": False
}
r = requests.post(api_url, headers=headers, json=data)
if r.status_code == 201:
print("[OK] Created repo on Gitea:", git_url)
elif r.status_code == 409:
print("[NOTE] Repo already exists on Gitea:", git_url)
else:
print("[ERROR] Could not create repo:", r.status_code, r.text)
sys.exit(1)
# --- Set git remote and push ---
try:
subprocess.check_call(["git", "remote", "remove", "origin"])
except subprocess.CalledProcessError:
pass
subprocess.check_call(["git", "remote", "add", "origin", git_url])
subprocess.check_call(["git", "push", "-u", "origin", "master"])
print("[OK] Repo pushed to Gitea!")