diff --git a/.github/workflows/merge_repos_action.yml b/.github/workflows/merge_repos_action.yml index 5782a84..78f03cf 100644 --- a/.github/workflows/merge_repos_action.yml +++ b/.github/workflows/merge_repos_action.yml @@ -1,4 +1,4 @@ -name: merge_repos_action +name: Merge Repos Action on: workflow_dispatch: @@ -11,6 +11,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 + - name: Set up SSH + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan github.com >> ~/.ssh/known_hosts + - name: Set up Python uses: actions/setup-python@v2 with: @@ -19,7 +26,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install gitpython - name: Run merge_repos.py + env: + GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} run: | python merge_repos.py diff --git a/merge_repos.py b/merge_repos.py index ce47b77..800d883 100644 --- a/merge_repos.py +++ b/merge_repos.py @@ -1 +1,18 @@ -print("hello") \ No newline at end of file +import os +import git # type: ignore + +def clone_repo(repo_url, repo_path): + if not os.path.exists(repo_path): + git.Repo.clone_from(repo_url, repo_path) + return git.Repo(repo_path) + +def main(): + # Replace with your actual GitHub username + repo_url = "git@github.com:lsfreitas/target.git" + repo_path = "/tmp/target_repo" + + repo = clone_repo(repo_url, repo_path) + print(f"Repository cloned to {repo_path}") + +if __name__ == "__main__": + main() \ No newline at end of file