diff --git a/scripts/deploy.py b/scripts/deploy.py index 81d22ce..d14d0fb 100644 --- a/scripts/deploy.py +++ b/scripts/deploy.py @@ -11,6 +11,15 @@ except ImportError: ) sys.exit() +try: + import yaml + +except ImportError: + print( + "You need to install `yaml` to use this file. Run `pip install pyyaml` and try again." + ) + sys.exit() + username = input("Username for git.nyeki.dev: ") password = getpass.getpass("Password for git.nyeki.dev: ") @@ -34,9 +43,14 @@ print("Waiting 15 seconds to run migrations...") time.sleep(15) -shards = input("How many shards are there deployed?: ") +with open("./k8s/bot.yml") as stream: + try: + data = yaml.safe_load(stream) + + os.system(f"microk8s kubectl exec bot-{data["spec"]["replicas"] - 1} -- uv run aerich upgrade") + except yaml.YAMLError as exc: + print("Could not read the amount of deployed shards.") -os.system(f"microk8s kubectl exec bot-{int(shards) - 1} -- uv run aerich upgrade") print("Done!")