From 4ef433312dd0b0ace91b3c285f82f3973093d92d Mon Sep 17 00:00:00 2001 From: decentral1se Date: Sat, 5 Jun 2021 22:41:50 +0200 Subject: [PATCH] Add mirroring script --- Dockerfile | 3 +-- bin/abralib.py | 1 + bin/github-sync.py | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 bin/github-sync.py diff --git a/Dockerfile b/Dockerfile index 9b534ac5..a794795e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,6 @@ RUN chmod +x ~/.abra/vendor/yq # otherwise give us the latest abra on the latest tag RUN curl https://install.abra.coopcloud.tech | bash -s -- --dev -COPY bin/abralib.py /root/.local/bin/abralib.py -COPY bin/app-json.py /root/.local/bin/app-json.py +COPY bin/* /root/.local/bin/ ENTRYPOINT ["/root/.local/bin/abra"] diff --git a/bin/abralib.py b/bin/abralib.py index 95d59dc1..2e05934a 100644 --- a/bin/abralib.py +++ b/bin/abralib.py @@ -18,6 +18,7 @@ REPOS_TO_SKIP = ( "abra-gandi", "abra-hetzner", "auto-apps-json", + "auto-mirror", "backup-bot", "coopcloud.tech", "coturn", diff --git a/bin/github-sync.py b/bin/github-sync.py new file mode 100755 index 00000000..e537d1b8 --- /dev/null +++ b/bin/github-sync.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 + +# Usage: ./github-sync.py +# +# Mirror repositories to Github (Fuck M$, get it straight) + +from os import chdir, listdir + +from abralib import ( + CLONES_PATH, + REPOS_TO_SKIP, + _run_cmd, + clone_all_apps, + get_repos_json, + log, +) + + +def main(): + """Run the script.""" + repos_json = get_repos_json() + clone_all_apps(repos_json) + + for app in listdir(CLONES_PATH): + if app in REPOS_TO_SKIP: + log.info(f"Skipping {app}") + continue + + app_path = f"{CLONES_PATH}/{app}" + chdir(app_path) + + log.info(f"Mirroring {app}...") + + _run_cmd( + f"git remote add github git@github.com:Autonomic-Cooperative/{app}.git || true", + shell=True, + ) + _run_cmd("git push github --all") + + +main()