This repository has been archived on 2021-07-03. You can view files and clone it, but cannot push or open issues or pull requests.
abra/bin/github-sync.py
2021-06-17 07:43:00 +02:00

46 lines
914 B
Python
Executable File

#!/usr/bin/env python3
# Usage: ./github-sync.py
#
# Mirror repositories to Github (Fuck M$, get it straight)
from os import chdir, environ, 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}...")
token = environ.get("GITHUB_ACCESS_TOKEN")
remote = f"https://coopcloudbot:{token}@github.com/Co-op-Cloud/{app}.git"
_run_cmd(
f"git remote add github {remote} || true",
shell=True,
)
_run_cmd("git push github --all")
main()