Entry point: parse config, sync item to project, set status and date.
()
| 296 | |
| 297 | |
| 298 | def main() -> None: |
| 299 | """Entry point: parse config, sync item to project, set status and date.""" |
| 300 | config = Config.from_env() |
| 301 | |
| 302 | if not config.project_owner: |
| 303 | raise SystemExit("PROJECT_OWNER is required") |
| 304 | |
| 305 | print(f"Looking up project: {config.project_owner}#{config.project_number}") |
| 306 | project_id = find_project( |
| 307 | config.project_owner, config.project_owner_type, config.project_number |
| 308 | ) |
| 309 | print(f"Project ID: {project_id}") |
| 310 | |
| 311 | print(f"Adding item {config.item_node_id} to project") |
| 312 | item_id = add_item_to_project(project_id, config.item_node_id) |
| 313 | print(f"Project item ID: {item_id}") |
| 314 | |
| 315 | status_name = determine_status(config) |
| 316 | print(f"Setting status to: {status_name}") |
| 317 | resolved = get_field_and_option(project_id, config.status_field, status_name) |
| 318 | update_single_select(project_id, item_id, resolved.field_id, resolved.option_id) |
| 319 | print("Status updated") |
| 320 | |
| 321 | if config.date_field and config.event_action in ("opened", "ready_for_review"): |
| 322 | today = datetime.now(timezone.utc).strftime("%Y-%m-%d") |
| 323 | print(f"Setting {config.date_field} to {today}") |
| 324 | date_field_id = get_date_field(project_id, config.date_field) |
| 325 | update_date(project_id, item_id, date_field_id, today) |
| 326 | print("Date updated") |
| 327 | |
| 328 | print("Done") |
| 329 | |
| 330 | |
| 331 | if __name__ == "__main__": |
no test coverage detected