From d53ea45d2a1e25939b63671a92e94faa9d222eb2 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:21:01 +0900 Subject: [PATCH 1/4] add dry run for local testing --- scripts/deploy_util.py | 24 ++++++++++++++++-------- scripts/login_and_get_token.py | 6 ++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/scripts/deploy_util.py b/scripts/deploy_util.py index 32552af2238..01ef1989b2d 100644 --- a/scripts/deploy_util.py +++ b/scripts/deploy_util.py @@ -21,6 +21,7 @@ ] DEPLOY_TRIGGER = os.getenv("DEPLOY_TRIGGER") +DRY_RUN = bool(int(os.getenv("DRY_RUN") or 0)) GITHUB_STEP_SUMMARY_FILE = os.getenv("GITHUB_STEP_SUMMARY") USER_AGENT = f"GitHub Autodeploy Bot/2.0.0 ({os.getenv('WIKI_UA_EMAIL')})" WIKI_BASE_URL = os.getenv("WIKI_BASE_URL") @@ -64,20 +65,27 @@ def deploy_file_to_wiki( token: str, deploy_reason: str, ) -> tuple[bool, bool]: - change_made = False - deployed = True - response = session.post( - get_wiki_api_url(wiki), - headers=HEADER, - params={"format": "json", "action": "edit"}, - data={ + payload = { "title": target_page, "text": file_content, "summary": f"Git: {deploy_reason}", "bot": "true", "recreate": "true", "token": token, - }, + } + if DRY_RUN: + print(f"HEADER: {HEADER}") + print(f"PARAM: { {"format": "json", "action": "edit"} }") + print(f"DATA: {payload}") + return True, False + + change_made = False + deployed = True + response = session.post( + get_wiki_api_url(wiki), + headers=HEADER, + params={"format": "json", "action": "edit"}, + data=payload, ).json() edit_info = response.get("edit") error_info = response.get("error") diff --git a/scripts/login_and_get_token.py b/scripts/login_and_get_token.py index d91b92afd10..0a88e292fc2 100644 --- a/scripts/login_and_get_token.py +++ b/scripts/login_and_get_token.py @@ -8,6 +8,7 @@ __all__ = ["get_token"] +DRY_RUN = bool(int(os.getenv("DRY_RUN") or 0)) WIKI_USER = os.getenv("WIKI_USER") WIKI_PASSWORD = os.getenv("WIKI_PASSWORD") @@ -19,6 +20,8 @@ def login(wiki: str): return cookie_jar = read_cookie_jar(wiki) print(f"...logging in on {wiki}") + if DRY_RUN: + return with requests.Session() as session: session.cookies = cookie_jar token_response = session.post( @@ -50,6 +53,9 @@ def login(wiki: str): def get_token(wiki: str) -> str: login(wiki) + if DRY_RUN: + return 'DRY_RUN_DUMMY_TOKEN' + with requests.Session() as session: session.cookies = read_cookie_jar(wiki) token_response = session.post( From 911c2a90dcd14fdfbf13325205e5174f4a30e255 Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:21:33 +0900 Subject: [PATCH 2/4] use full path --- scripts/deploy_res.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/deploy_res.py b/scripts/deploy_res.py index 2b30f76a840..1a0020715bc 100644 --- a/scripts/deploy_res.py +++ b/scripts/deploy_res.py @@ -31,7 +31,7 @@ def deploy_resources( file_content = read_file_from_path(file_path) page = ( f"MediaWiki:Common.{'js' if res_type == '.js' else 'css'}/" - + file_path.name + + "/".join(file_path.parts[2:]) ) print(f"...page = {page}") deploy_result = deploy_file_to_wiki( @@ -74,8 +74,8 @@ def main(): git_deploy_reason: str if len(sys.argv[1:]) == 0: resource_files = itertools.chain( - pathlib.Path("./javascript/").rglob("*.js"), - pathlib.Path("./stylesheets/").rglob("*.scss"), + pathlib.Path("./javascript/commons/").rglob("*.js"), + pathlib.Path("./stylesheets/commons/").rglob("*.scss"), ) git_deploy_reason = "Automated Weekly Re-Sync" else: From 4d4887c47c42c89cb779a70111f645f8fb8e278a Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:26:06 +0900 Subject: [PATCH 3/4] lint --- scripts/deploy_util.py | 16 ++++++++-------- scripts/login_and_get_token.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/deploy_util.py b/scripts/deploy_util.py index 01ef1989b2d..ebff4c3e5d4 100644 --- a/scripts/deploy_util.py +++ b/scripts/deploy_util.py @@ -66,16 +66,16 @@ def deploy_file_to_wiki( deploy_reason: str, ) -> tuple[bool, bool]: payload = { - "title": target_page, - "text": file_content, - "summary": f"Git: {deploy_reason}", - "bot": "true", - "recreate": "true", - "token": token, - } + "title": target_page, + "text": file_content, + "summary": f"Git: {deploy_reason}", + "bot": "true", + "recreate": "true", + "token": token, + } if DRY_RUN: print(f"HEADER: {HEADER}") - print(f"PARAM: { {"format": "json", "action": "edit"} }") + print(f"PARAM: { {'format': 'json', 'action': 'edit'} }") print(f"DATA: {payload}") return True, False diff --git a/scripts/login_and_get_token.py b/scripts/login_and_get_token.py index 0a88e292fc2..fb4e18a9027 100644 --- a/scripts/login_and_get_token.py +++ b/scripts/login_and_get_token.py @@ -54,7 +54,7 @@ def get_token(wiki: str) -> str: login(wiki) if DRY_RUN: - return 'DRY_RUN_DUMMY_TOKEN' + return "DRY_RUN_DUMMY_TOKEN" with requests.Session() as session: session.cookies = read_cookie_jar(wiki) From c467139a40b7dd45793e3fec79c78d8f13aa5eaa Mon Sep 17 00:00:00 2001 From: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com> Date: Tue, 24 Mar 2026 15:03:07 +0900 Subject: [PATCH 4/4] use default value --- scripts/deploy_util.py | 2 +- scripts/login_and_get_token.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/deploy_util.py b/scripts/deploy_util.py index ebff4c3e5d4..dc4060f635e 100644 --- a/scripts/deploy_util.py +++ b/scripts/deploy_util.py @@ -21,7 +21,7 @@ ] DEPLOY_TRIGGER = os.getenv("DEPLOY_TRIGGER") -DRY_RUN = bool(int(os.getenv("DRY_RUN") or 0)) +DRY_RUN = bool(int(os.getenv("DRY_RUN", 0))) GITHUB_STEP_SUMMARY_FILE = os.getenv("GITHUB_STEP_SUMMARY") USER_AGENT = f"GitHub Autodeploy Bot/2.0.0 ({os.getenv('WIKI_UA_EMAIL')})" WIKI_BASE_URL = os.getenv("WIKI_BASE_URL") diff --git a/scripts/login_and_get_token.py b/scripts/login_and_get_token.py index fb4e18a9027..2f6afa81b33 100644 --- a/scripts/login_and_get_token.py +++ b/scripts/login_and_get_token.py @@ -8,7 +8,7 @@ __all__ = ["get_token"] -DRY_RUN = bool(int(os.getenv("DRY_RUN") or 0)) +DRY_RUN = bool(int(os.getenv("DRY_RUN", 0))) WIKI_USER = os.getenv("WIKI_USER") WIKI_PASSWORD = os.getenv("WIKI_PASSWORD")