build(bot): ✨ Pull new tags from the container image registry instead of from pyproject.toml.
This commit is contained in:
+29
-7
@@ -2,21 +2,43 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import toml
|
import requests
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print(
|
print(
|
||||||
"You need to install `toml` to use this file. Run `pip install toml` and try again."
|
"You need to install `requests` to use this file. Run `pip install requests` and try "
|
||||||
|
"again."
|
||||||
)
|
)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
version = toml.load(open("pyproject.toml"))["project"]["version"].split(".")[1]
|
username = input("Username for git.nyeki.dev: ")
|
||||||
|
password = input("Password for git.nyeki.dev: ")
|
||||||
|
|
||||||
os.system("git pull")
|
tags = requests.get(
|
||||||
os.system(f"microk8s kubectl set image sts/bot bot=git.nyeki.dev/payphone/payphone-shard:v{version}")
|
"https://git.nyeki.dev/v2/payphone/payphone-shard/tags/list",
|
||||||
os.system(f"""
|
auth=(username, password),
|
||||||
|
).json()["tags"]
|
||||||
|
|
||||||
|
latest_version = 1
|
||||||
|
|
||||||
|
for tag in tags:
|
||||||
|
tag: str
|
||||||
|
|
||||||
|
if tag[1:].isdecimal():
|
||||||
|
version = int(tag[1:])
|
||||||
|
|
||||||
|
if version > latest_version:
|
||||||
|
latest_version = version
|
||||||
|
|
||||||
|
os.system(f"git pull https://{username}:{password}@git.nyeki.dev/payphone/payphone")
|
||||||
|
os.system(
|
||||||
|
f"microk8s kubectl set image sts/bot bot=git.nyeki.dev/payphone/payphone-shard:v{version}"
|
||||||
|
)
|
||||||
|
os.system(
|
||||||
|
f"""
|
||||||
microk8s kubectl set image deploy/tasks \
|
microk8s kubectl set image deploy/tasks \
|
||||||
flush=git.nyeki.dev/payphone/payphone-shard:v{version} \
|
flush=git.nyeki.dev/payphone/payphone-shard:v{version} \
|
||||||
delete-accounts=git.nyeki.dev/payphone/payphone-shard:v{version} \
|
delete-accounts=git.nyeki.dev/payphone/payphone-shard:v{version} \
|
||||||
hangup-inactive-calls=git.nyeki.dev/payphone/payphone-shard:v{version}
|
hangup-inactive-calls=git.nyeki.dev/payphone/payphone-shard:v{version}
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user