diff --git a/.github/scripts/parse_schedule.py b/.github/scripts/parse_schedule.py new file mode 100644 index 00000000..6cf18384 --- /dev/null +++ b/.github/scripts/parse_schedule.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 +import os +import re +from datetime import datetime, timedelta, timezone +from zoneinfo import ZoneInfo + +SCHEDULE_TIMEZONE = "America/Chicago" +MAX_SCHEDULE_DAYS = 30 + + +def write_output(key: str, value: str) -> None: + path = os.environ.get("GITHUB_OUTPUT") + if not path: + return + with open(path, "a", encoding="utf-8") as handle: + handle.write(f"{key}={value}\n") + + +def fail(message: str) -> None: + write_output("valid", "false") + write_output("error", message) + + +raw = os.environ.get("RAW", "").strip() +if not raw: + fail("Missing schedule time.") + raise SystemExit(0) + +normalized = re.sub(r"\s+", " ", raw).strip() +match = re.match( + r"^(?P\d{4}-\d{2}-\d{2})\s+(?P