import os from github import Github from dotenv import load_dotenv from utils import log def upload_to_github(file_path, content): load_dotenv(override=True) g = Github(os.getenv("GITHUB_TOKEN")) repo = g.get_repo("ljm565/adminsim-human-eval") try: contents = None try: contents = repo.get_contents(file_path, ref="main") except Exception: pass if contents is None: repo.create_file(file_path, "feat: Add new results", content, branch="main") log(f"File created successfully at {file_path}!") else: repo.update_file(file_path, "feat: Update the results", content, contents.sha, branch="main") log(f"File updated successfully at {file_path}!") except Exception as e: log(f"An error occurred: {e}", level="error")