File size: 1,146 Bytes
97243fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
from git import Repo

# Define your GitHub and Hugging Face repository details
github_repo_url = "https://github.com/Vignesh2064/tt-oilwells-demo-model.git"
hf_username = "Imvignesh"
hf_repo_name = "tt-oilwells-demo-model"
hf_token = os.getenv('HF_TOKEN')  # Ensure HF_TOKEN is set in your environment secrets

def main():
    # Clone the GitHub repository locally
    repo_dir = "tt-oilwells-demo-model"
    Repo.clone_from(github_repo_url, repo_dir)
    os.chdir(repo_dir)

    # Add the Hugging Face repository as a remote
    hf_remote_url = f"https://{hf_username}:{hf_token}@huggingface.co/{hf_username}/{hf_repo_name}.git"
    repo = Repo(".")

    try:
        hf_remote = repo.create_remote("hf_origin", hf_remote_url)
    except:
        hf_remote = repo.remote("hf_origin")
        hf_remote.set_url(hf_remote_url)

    # Push the GitHub repository files to Hugging Face
    repo.git.add(".")
    repo.index.commit("Initial commit from GitHub repository")
    repo.git.push("--set-upstream", "hf_origin", "HEAD:main")

    print("Files pushed successfully to Hugging Face repository.")

if __name__ == "__main__":
    main()