|
def commit_and_push_changes(): |
|
import os |
|
import subprocess |
|
from pathlib import Path |
|
|
|
|
|
REPO_DIR = Path(".") |
|
DATA_DIR = REPO_DIR / "data/questions" |
|
JSONL_FILE = REPO_DIR / "output.jsonl" |
|
|
|
DATA_DIR.mkdir(parents=True, exist_ok=True) |
|
|
|
GIT_USER = os.getenv("GIT_USER") |
|
GIT_EMAIL = os.getenv("GIT_EMAIL") |
|
HF_OWNER = os.getenv("HF_OWNER") |
|
HF_TOKEN = os.getenv("HF_TOKEN") |
|
REPO_NAME = os.getenv("REPO_NAME") |
|
REPO_URL = f"https://{HF_OWNER}:{HF_TOKEN}@huggingface.co/spaces/{REPO_NAME}" |
|
|
|
|
|
|
|
"""Automates Git add, commit, and push for updated data.""" |
|
try: |
|
|
|
subprocess.run(["git", "config", "--global", "user.name", GIT_USER], check=True) |
|
subprocess.run(["git", "config", "--global", "user.email", GIT_EMAIL], check=True) |
|
subprocess.run(["git", "remote", "set-url", "origin", REPO_URL], check=True) |
|
subprocess.run(["git", "add", "--all"], check=True) |
|
subprocess.run(["git", "commit", "-m", "Update questions data"], check=True) |
|
subprocess.run(["git", "push", "origin", "main"], check=True) |
|
print("β
Data committed and pushed successfully!") |
|
|
|
except subprocess.CalledProcessError as e: |
|
print(f"β Git operation failed: {e}") |