forked from nikhilbadyal/docker-py-revanced
-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_resource_updates.py
46 lines (40 loc) · 1.59 KB
/
check_resource_updates.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""Check patching resource updates."""
from environs import Env
from loguru import logger
from main import get_app
from src.config import RevancedConfig
from src.manager.github import GitHubManager
from src.utils import default_build, patches_dl_key, patches_version_key
def check_if_build_is_required() -> bool:
"""Read resource version."""
env = Env()
env.read_env()
config = RevancedConfig(env)
needs_to_repatched = []
for app_name in env.list("PATCH_APPS", default_build):
logger.info(f"Checking {app_name}")
app_obj = get_app(config, app_name)
old_patches_version = GitHubManager(env).get_last_version(app_obj, patches_version_key)
old_patches_source = GitHubManager(env).get_last_version_source(app_obj, patches_dl_key)
app_obj.download_patch_resources(config)
if GitHubManager(env).should_trigger_build(
old_patches_version,
old_patches_source,
app_obj.resource["patches"]["version"],
app_obj.patches_dl,
):
caused_by = {
"app_name": app_name,
"patches": {
"old": old_patches_version,
"new": app_obj.resource["patches"]["version"],
},
}
logger.info(f"New build can be triggered caused by {caused_by}")
needs_to_repatched.append(app_name)
logger.info(f"{needs_to_repatched} are need to repatched.")
if needs_to_repatched:
print(",".join(needs_to_repatched)) # noqa: T201
return True
return False
check_if_build_is_required()