Skip to content
Myr

🔨 Update deploy docs preview script (#1079)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sebastián Ramírez · committed by GitHub · parent 27a1c8e · Browse files · 1 file+23 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+23 added−9 removed

  • other:+23 added−9 removed

1 file+23 added−9 removed

modified:scripts/deploy_docs_status.py+23 added-9 removed
1import logging2import re34from github import Github5from pydantic import SecretStr5from pydantic import BaseModel, SecretStr6from pydantic_settings import BaseSettings78site_domain = "typer.tiangolo.com"91011class Settings(BaseSettings):12 github_repository: str13 github_token: SecretStr14 deploy_url: str | None = None
1 unmodified line
16 run_id: int17 is_done: bool = False181920class LinkData(BaseModel):21 previous_link: str22 preview_link: str232418def main():25def main() -> None:26 logging.basicConfig(level=logging.INFO)27 settings = Settings()2829 logging.info(f"Using config: {settings.model_dump_json()}")
36 unmodified lines
66 files = list(use_pr.get_files())67 docs_files = [f for f in files if f.filename.startswith("docs/")]6869 deploy_url = settings.deploy_url.rstrip("/")63 links: list[str] = []70 links: list[LinkData] = []71 for f in docs_files:72 match = re.match(r"docs/(.*)", f.filename)66 assert match73 if not match:74 continue75 path = match.group(1)76 if path.endswith("index.md"):69 path = path.replace("index.md", "")77 use_path = path.replace("index.md", "")78 else:71 path = path.replace(".md", "/")72 link = f"{deploy_url}/{path}"79 use_path = path.replace(".md", "/")80 link = LinkData(81 previous_link=f"https://{site_domain}/{use_path}",82 preview_link=f"{deploy_url}/{use_path}",83 )84 links.append(link)74 links.sort()85 links.sort(key=lambda x: x.preview_link)8687 message = f"📝 Docs preview for commit {settings.commit_sha} at: {deploy_url}"8889 if links:90 message += "\n\n### Modified Pages\n\n"80 message += "\n".join([f"* {link}" for link in links])91 for link in links:92 message += f"* {link.preview_link}"93 message += f" - ([before]({link.previous_link}))"94 message += "\n"9596 print(message)97 use_pr.as_issue().create_comment(message)98
5 unmodified lines