From 9fadc430a7bb2d554c0ee26c0f9b6c51dc5b0475 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 3 Jun 2021 11:40:55 +0200 Subject: [PATCH] Add renovate script --- bin/renovate-ls-apps.py | 88 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 bin/renovate-ls-apps.py diff --git a/bin/renovate-ls-apps.py b/bin/renovate-ls-apps.py new file mode 100755 index 0000000..3eb422f --- /dev/null +++ b/bin/renovate-ls-apps.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 + +# Usage: ./renovate-ls-apps.py +# +# Output list of apps for Renovate bot configuration + +from logging import DEBUG, basicConfig, getLogger +from os.path import expanduser +from pathlib import Path +from shlex import split +from subprocess import check_output +from sys import exit + +from requests import get + +HOME_PATH = expanduser("~/") +CLONES_PATH = Path(f"{HOME_PATH}/.abra/apps").absolute() +YQ_PATH = Path(f"{HOME_PATH}/.abra/vendor/yq") +SCRIPT_PATH = Path(__file__).absolute().parent +REPOS_TO_SKIP = ( + "abra", + "abra-apps", + "abra-gandi", + "abra-hetzner", + "backup-bot", + "coopcloud.tech", + "coturn", + "docker-cp-deploy", + "docker-dind-bats-kcov", + "docs.coopcloud.tech", + "example", + "gardening", + "organising", + "pyabra", + "radicle-seed-node", + "stack-ssh-deploy", + "swarm-cronjob", +) + +log = getLogger(__name__) +basicConfig() +log.setLevel(DEBUG) + + +def _run_cmd(cmd, shell=False, **kwargs): + """Run a shell command.""" + args = [split(cmd)] + + if shell: + args = [cmd] + kwargs = {"shell": shell} + + try: + return check_output(*args, **kwargs).decode("utf-8").strip() + except Exception as exception: + log.error(f"Failed to run {cmd}, saw {str(exception)}") + exit(1) + + +def get_repos_json(): + """ Retrieve repo list from Gitea """ + url = "https://git.autonomic.zone/api/v1/orgs/coop-cloud/repos" + + repos = [] + response = True + page = 1 + + try: + while response: + response = get(url + f"?page={page}", timeout=10).json() + repos.extend(response) + page += 1 + + return repos + except Exception as exception: + log.error(f"Failed to retrieve {url}, saw {str(exception)}") + exit(1) + + +def main(): + """Run the script.""" + repos = [p["full_name"] for p in get_repos_json()] + repos.sort() + for repo in repos: + print(f'"{repo}",') + + +main()