diff options
| author | git user <git@git.suspectdevices.com> | 2026-08-04 19:46:43 -0700 |
|---|---|---|
| committer | git user <git@git.suspectdevices.com> | 2026-08-04 19:46:43 -0700 |
| commit | 9c50eca7153b778722d7a90c33574795795643e3 (patch) | |
| tree | 4edeee5c72ce93aa2f7c7083ee463727c393e498 | |
| parent | e70306280b8b36f071b2226d95f073f1302796b3 (diff) | |
draft of cronable
| -rwxr-xr-x | update_mirrors.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/update_mirrors.py b/update_mirrors.py new file mode 100755 index 0000000..e372238 --- /dev/null +++ b/update_mirrors.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 + +import os +import subprocess +from github import Github +from github import Auth +from dotenv import load_dotenv + +load_dotenv() + +auth_token = os.environ["AUTH_TOKEN"] + +def mygithub() : + auth = Auth.Token(auth_token) + g = Github(auth=auth) + return g + +def myrepos() : + repos=[] + g = mygithub() + for repo in g.get_user().get_repos(): + repos.append(repo.ssh_url) + g.close() + return(repos) + +if __name__ == "__main__": + + local_prefix="/srv/git/mirrors/github/" + + for url in myrepos(): + #print(url) + local_copy=local_prefix+url.split(':')[1] + if os.path.isdir(local_copy): + print("updating local copy: " + local_copy) + result=subprocess.run(["git", "remote", "update"],cwd=local_copy, capture_output=True) + print(result.stdout.decode()) + else: + print("create new mirror at: "+local_copy) + result=subprocess.run(["git","clone","--mirror", url, local_copy], capture_output=True) + print(result.stdout.decode()) + + #print(local_copy) + #mypath="/srv/git/mirrors/github/"+repo.ssh_url.split(':')[1] + #print("git clone --mirror " +repo.ssh_url+" "+mypath) +
\ No newline at end of file |
