Skip to content

Commit

Permalink
add clone_repo function
Browse files Browse the repository at this point in the history
  • Loading branch information
Luís Freitas authored and Luís Freitas committed Jun 30, 2024
1 parent c5077bc commit 140041c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/merge_repos_action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: merge_repos_action
name: Merge Repos Action

on:
workflow_dispatch:
Expand All @@ -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:
Expand All @@ -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
19 changes: 18 additions & 1 deletion merge_repos.py
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
print("hello")
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 = "[email protected]: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()

0 comments on commit 140041c

Please sign in to comment.