abra-bash/bin/github-sync.py

50 lines
1.0 KiB
Python
Raw Permalink Normal View History

2021-06-05 20:41:50 +00:00
#!/usr/bin/env python3
# Usage: ./github-sync.py
#
# Mirror repositories to Github (Fuck M$, get it straight)
2021-06-05 20:54:16 +00:00
from os import chdir, environ, listdir
2021-06-05 20:41:50 +00:00
from abralib import CLONES_PATH, _run_cmd, clone_all_apps, get_repos_json, log
REPOS_TO_SKIP = (
2021-07-08 15:53:03 +00:00
"apps",
"backup-bot",
"docker-dind-bats-kcov",
"docs.coopcloud.tech",
"pyabra",
"radicle-seed-node",
"swarm-cronjob",
2021-07-06 12:43:03 +00:00
"tyop",
2021-06-05 20:41:50 +00:00
)
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}...")
2021-06-05 20:54:16 +00:00
token = environ.get("GITHUB_ACCESS_TOKEN")
2021-06-17 14:34:03 +00:00
remote = f"https://coopcloudbot:{token}@github.com/Coop-Cloud/{app}.git"
2021-06-05 20:54:16 +00:00
2021-06-05 20:41:50 +00:00
_run_cmd(
2021-06-05 20:54:16 +00:00
f"git remote add github {remote} || true",
2021-06-05 20:41:50 +00:00
shell=True,
)
2021-06-05 20:54:16 +00:00
2021-06-05 20:41:50 +00:00
_run_cmd("git push github --all")
main()