git credentials for vm on hf
#3
by
ratneshpasi03
- opened
- utils/save_to_hf.py +8 -4
utils/save_to_hf.py
CHANGED
@@ -11,19 +11,23 @@ def commit_and_push_changes():
|
|
11 |
DATA_DIR.mkdir(parents=True, exist_ok=True) # Ensure directory exists
|
12 |
|
13 |
GIT_USER = os.getenv("GIT_USER")
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
16 |
|
17 |
# Set remote URL before pushing
|
18 |
-
subprocess.run(["git", "remote", "set-url", "origin", REPO_URL], check=True)
|
19 |
|
20 |
"""Automates Git add, commit, and push for updated data."""
|
21 |
try:
|
22 |
# Run Git commands
|
|
|
|
|
|
|
23 |
subprocess.run(["git", "add", "--all"], check=True)
|
24 |
subprocess.run(["git", "commit", "-m", "Update questions data"], check=True)
|
25 |
subprocess.run(["git", "push"], check=True)
|
26 |
-
|
27 |
print("β
Data committed and pushed successfully!")
|
28 |
|
29 |
except subprocess.CalledProcessError as e:
|
|
|
11 |
DATA_DIR.mkdir(parents=True, exist_ok=True) # Ensure directory exists
|
12 |
|
13 |
GIT_USER = os.getenv("GIT_USER")
|
14 |
+
GIT_EMAIL = os.getenv("GIT_EMAIL")
|
15 |
+
HF_OWNER = os.getenv("HF_OWNER")
|
16 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
17 |
+
REPO_NAME = os.getenv("REPO_NAME")
|
18 |
+
REPO_URL = f"https://{HF_OWNER}:{HF_TOKEN}@huggingface.co/spaces/{REPO_NAME}"
|
19 |
|
20 |
# Set remote URL before pushing
|
|
|
21 |
|
22 |
"""Automates Git add, commit, and push for updated data."""
|
23 |
try:
|
24 |
# Run Git commands
|
25 |
+
subprocess.run(["git", "config", "--global", "user.name", GIT_USER], check=True)
|
26 |
+
subprocess.run(["git", "config", "--global", "user.email", GIT_EMAIL], check=True)
|
27 |
+
subprocess.run(["git", "remote", "set-url", "origin", REPO_URL], check=True)
|
28 |
subprocess.run(["git", "add", "--all"], check=True)
|
29 |
subprocess.run(["git", "commit", "-m", "Update questions data"], check=True)
|
30 |
subprocess.run(["git", "push"], check=True)
|
|
|
31 |
print("β
Data committed and pushed successfully!")
|
32 |
|
33 |
except subprocess.CalledProcessError as e:
|