from git import Repo import os import shutil # Retrieve the environment variables GITHUB_PAT = os.getenv('GITHUB_PAT') GIT_id = os.getenv('GIT_id') GIT_repo = os.getenv('GIT_repo') if GITHUB_PAT: print("GITHUB_PAT set") if not os.path.exists('cloned_repo'): # Clone the repository using the Personal Access Token for authentication Repo.clone_from(f'https://{GIT_id}:{GITHUB_PAT}@github.com/{GIT_id}/{GIT_repo}.git', './cloned_repo') # Move all files from the cloned_repo directory to the current directory for item in os.listdir('cloned_repo'): source_path = os.path.join('cloned_repo', item) destination_path = os.path.join('.', item) # If it's a file, move it directly if os.path.isfile(source_path): shutil.move(source_path, destination_path) # If it's a directory, move the entire directory elif os.path.isdir(source_path): if os.path.exists(destination_path): shutil.rmtree(destination_path) # Remove if the directory already exists shutil.move(source_path, destination_path) # Now you can import the main module from the current directory import main from main import *